# Path length limitation in Windows lifted

**URL:** https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545
**Category:** Engineering
**Created:** [December 22, 2017, 2:44am UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545 "2017-12-22T02:44:32Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [December 22, 2017, 2:44am UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/1 "2017-12-22T02:44:32Z")

</div>

With a recent version of Windows 10, paths longer than 260 characters can be enabled. But we need to account for that possibility in ITK in order to take advantage of it.

> **[Long path using ninja](https://discourse.slicer.org/t/long-path-using-ninja/1702/5)**
>
> After re-running ninja, I get the same error: -- Configuring done CMake Warning in Modules/Loadable/VolumeRendering/SubjectHierarchyPlugins/CMakeLists.txt: The object file directory ...

---

<div class="post-metadata">

### Author: ![fbudin](https://discourse.itk.org/user_avatar/discourse.itk.org/fbudin/32/14_2.png) [@fbudin](https://discourse.itk.org/u/fbudin)
#### Post date: [December 22, 2017, 8:15pm UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/2 "2017-12-22T20:15:56Z")

</div>

I guess this is related to this: When installing Python (at least the latest version) on Windows, there is an option to “Disable path length limit”.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [December 23, 2017, 7:06pm UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/3 "2017-12-23T19:06:28Z")

</div>

[Patch](http://review.source.kitware.com/#/c/22943) and [commit](https://github.com/InsightSoftwareConsortium/ITK/commit/1dd3bfc7ee4963332fd38eb2f8949ef1c2339ff0) for the fix.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.itk.org/user_avatar/discourse.itk.org/lassoan/32/27_2.png) [@lassoan](https://discourse.itk.org/u/lassoan)
#### Post date: [December 23, 2017, 8:20pm UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/4 "2017-12-23T20:20:22Z")

</div>

Total file path length of 32k characters have been available in Windows for many years (using in Unicode API, on NTFS disks), but MSBuild and other build tools have not been updated to take advantage of this.

In Windows10, probably it’ll be easier to update the tool chain to support longer file paths, but it is still probably a lot of work, so it is not likely to happen anytime soon. As you can see in this discussion, the developer team is quite reluctant to work on this (but there is hope): [https://github.com/Microsoft/msbuild/issues/53](https://github.com/Microsoft/msbuild/issues/53)

Also note that not only file paths but command line and environment size are limited, too. They impose limits on maximum file path lengths, too.

As a conclusion, I don’t think we can disable file path length checks just yet (regardless of LongPathsEnabled registry setting).

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [December 27, 2017, 3:48pm UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/5 "2017-12-27T15:48:37Z")

</div>

The registry key for disabling path length limitation is off by default. Since this [patch](http://review.source.kitware.com/#/c/22946/), the setting becomes visible for Windows versions on which the limit can be disabled. But user has to explicitly opt in, at least for now. Microsoft might change that in the future, once all the relevant tools get upgraded to work without issue with longer paths.

Without this option, there was no way to build ITK and projects which have it in its super-build (e.g. Slicer) in a longer path.

---

<div class="post-metadata">

### Author: ![fbudin](https://discourse.itk.org/user_avatar/discourse.itk.org/fbudin/32/14_2.png) [@fbudin](https://discourse.itk.org/u/fbudin)
#### Post date: [January 3, 2018, 3:36pm UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/6 "2018-01-03T15:36:56Z")

</div>

@lassoan Thanks for the interesting link. Out of curiosity, have you had a chance to test Slicer with this ITK patch?

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.itk.org/user_avatar/discourse.itk.org/lassoan/32/27_2.png) [@lassoan](https://discourse.itk.org/u/lassoan)
#### Post date: [January 3, 2018, 3:41pm UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/7 "2018-01-03T15:41:04Z")

</div>

Do you mean enabling long path support in Windows 10, disabling path length check in ITK, then trying to build Slicer in a long path?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [January 3, 2018, 3:41pm UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/8 "2018-01-03T15:41:33Z")

</div>

I tried it with patched ITK, and in some long build path. It failed - I don’t remember the exact reason. It was not ITK-related.

---

<div class="post-metadata">

### Author: ![fbudin](https://discourse.itk.org/user_avatar/discourse.itk.org/fbudin/32/14_2.png) [@fbudin](https://discourse.itk.org/u/fbudin)
#### Post date: [January 3, 2018, 3:41pm UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/9 "2018-01-03T15:41:44Z")

</div>

Indeed, that is what I was suggesting, but I guess there is no point to try if ITK doesn’t compile in a long path as @dzenanz just explained.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.itk.org/user_avatar/discourse.itk.org/lassoan/32/27_2.png) [@lassoan](https://discourse.itk.org/u/lassoan)
#### Post date: [January 3, 2018, 3:52pm UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/10 "2018-01-03T15:52:00Z")

</div>

I guess first we should just try if ITK can be built reliably in long paths. Have you checked that? In what paths exactly? With what Visual Studio version?

Note that long paths can cause environment size corruption/truncation, too - if you pass file paths via command-line arguments (see for example [https://github.com/commontk/CTK/issues/525](https://github.com/commontk/CTK/issues/525)).

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [January 3, 2018, 4:05pm UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/11 "2018-01-03T16:05:44Z")

</div>

It was using VS2015. The path was long, it didn’t have special characters in it (e.g. ž) or spaces. Post [here](https://discourse.slicer.org/t/long-path-using-ninja/1702/6).

---

<div class="post-metadata">

### Author: ![fbudin](https://discourse.itk.org/user_avatar/discourse.itk.org/fbudin/32/14_2.png) [@fbudin](https://discourse.itk.org/u/fbudin)
#### Post date: [January 3, 2018, 4:10pm UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/12 "2018-01-03T16:10:21Z")

</div>

I assumed too fast that this had been tested for ITK. I just checked with Windows10/Visual Studio 2017, and `LongPathsEnabled` set to 1, with ITK source and build directory in a long path (directory with about 150 characters in its name), and multiple errors arise:

1. At cloning time, git complains with errors like this one:

```auto
error: unable to create file Modules/Core/ImageFunction/include/itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunction.hxx: Filename too long

```

1. At configuration time, I get errors like this:

```auto
Data file referenced by argument

DATA{Baseline/itkMagnitudeAndPhaseToComplexImageFilterTestBaseline.mha}

corresponds to source tree path

Modules/Filtering/ImageIntensity/test/Baseline/itkMagnitudeAndPhaseToComplexImageFilterTestBaseline.mha

that does not exist as a file (with or without an extension)!
Call Stack (most recent call first):
CMake/ExternalData.cmake:485 (_ExternalData_arg)
CMake/ExternalData.cmake:324 (ExternalData_expand_arguments)
CMake/ITKModuleTest.cmake:127 (ExternalData_add_test)
Modules/Filtering/ImageIntensity/test/CMakeLists.txt:315 (itk_add_test)
This warning is for project developers. Use -Wno-dev to suppress it.

```

1. At generation time, I get:

```auto
CMake Error at Modules/ThirdParty/GDCM/src/gdcm/Source/DataStructureAndEncodingDefinition/CMakeLists.txt:87 (add_library):
Cannot find source file:

gdcmUNExplicitImplicitDataElement.cxx

Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx

```

1. When trying to open Visual Studio project, I get:

```auto
The operation could not be completed. The filename or extension is too long.

```

So there are indeed a lot of problems to overcome before this is usable.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [January 3, 2018, 4:41pm UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/13 "2018-01-03T16:41:57Z")

</div>

In practical terms, the path limit is higher with `LongPathsEnabled` set to 1. But it also probably depends on other pieces of the puzzle (CMake, VisualStudio, git etc). Could you try to figure out the new limit @fbudin?

---

<div class="post-metadata">

### Author: ![fbudin](https://discourse.itk.org/user_avatar/discourse.itk.org/fbudin/32/14_2.png) [@fbudin](https://discourse.itk.org/u/fbudin)
#### Post date: [January 3, 2018, 4:54pm UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/14 "2018-01-03T16:54:35Z")

</div>

FYI, the problem with `git clone` can be solved by running `git config --system core.longpaths true` beforehand ([here](https://stackoverflow.com/questions/22575662/filename-too-long-in-git-for-windows)). This also solves the CMake configuration and generation errors.

---

<div class="post-metadata">

### Author: ![fbudin](https://discourse.itk.org/user_avatar/discourse.itk.org/fbudin/32/14_2.png) [@fbudin](https://discourse.itk.org/u/fbudin)
#### Post date: [January 3, 2018, 8:33pm UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/15 "2018-01-03T20:33:28Z")

</div>

EDIT: Disabling the tests allowed me to successfully compile ITK with VS2017 and VS2013 (I do not have VS2015 to test)

As a final step, I tried to compile ITK with VS2017 (Windows 10): After reducing the path of the build directory to 69 characters to avoid the error mentioned above:

> [@fbudin](#):
>
> The operation could not be completed. The filename or extension is too long.

I was able to open Visual Studio, start the build, and I now get 5 failures (still due to the path being too long). So I think for now there is no way to work around the 260 characters limitation.

Disclaimer: I did not try any other path sizes than the ones mentioned in my posts (140 and 69).

---

<div class="post-metadata">

### Author: ![jackyflint1](https://discourse.itk.org/user_avatar/discourse.itk.org/jackyflint1/32/4663_2.png) [@jackyflint1](https://discourse.itk.org/u/jackyflint1)
#### Post date: [April 14, 2026, 12:19pm UTC](https://discourse.itk.org/t/path-length-limitation-in-windows-lifted/545/16 "2026-04-14T12:19:36Z")

</div>

LongPathTool handles build issues that persist even after Windows lifts path length limits
