Repository structure exceeds Windows Maximum Path Length



On Windows, the default maximum path length is set to 260 characters.

In my repository, this is being exceeded as the build path “C:\Users\travis\build\OrganizationName\respositoryName” in my case takes up 63 characters, then then it becomes reasonable to cross the limit. And this is before running CMake. For local development, we usually use “C:/work/repositoryName” or something similar to the prefix doesn’t take up a quarter of the max length.

I see 2 possibilities going forward:

  1. Allow using a custom directory. However, being realistic, I don’t think this is going to be entertained.
  2. The more realistic solution is that Microsoft has removed this limitation as of build 1607 (which is almost 2 years before 1803). The catch is that this is not default and requires opt-in.
    To quote the link above:

Starting in Windows 10, version 1607, MAX_PATH limitations have been removed from common Win32 file and directory functions. However, you must opt-in to the new behavior.

While it does say Windows 10, I’m assuming Windows Server is probably going to have this option available as well.

Can the windows images come with this enabled?



Hey @shehzan10,

Thanks for the suggestion. I agree that we should enable this in our VMs.

In the meantime, could you try to use the subst command to reduce current directory’s length e.g.

- |
  subst d: $TRAVIS_BUILD_DIR
- cd /d

Please let me know if this helps.



Hi Dominic

Thanks for your reply and suggestion. Do you think you’ll have a timeline for when this can be enabled?

Unfortunately, the error happens when trying to clone the repository, which happens before any travis steps are executed.

I can probably start testing with it by renaming some directories. Let’s see how that goes.



Nothing right now, but I did raise this with our people involved in the Windows project, so if we can get a timeline we’ll get back to you! :slight_smile:


Regarding Dominic’s suggestion of using subst, I’m testing it in a sandbox, however the command is running into the same error regardless of whether I use bash or powershell.

Link to the build: Not sure why the command gets substituted into the string.


So sorry about this.

You’ll indeed need to escape the colon. I’ve updated the snippet above but here is the corrected version:

- |
  subst d: $TRAVIS_BUILD_DIR
- cd /d