Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add longPathAware manifest to enable long paths on Windows #2225

Merged
merged 1 commit into from
Dec 15, 2022

Conversation

cristianadam
Copy link
Contributor

@cristianadam cristianadam commented Dec 12, 2022

Fixes: #1900 when the registry key Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled (Type: REG_DWORD) is set to 1

See https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation for more details.

@cristianadam
Copy link
Contributor Author

Given the following path: "c:\Projects\C++\this is a rather long path for a path on windows where long paths are a problem with the limit of two hundred fifty characters but there is a solution which implies adding a registry key and configuring the project to include a manifest\build.ninja" with build.ninja containing the string meh:

Ninja went from this error message:

c:\Projects\C++\this is a rather long path for a path on windows where long paths are a problem with the limit of two hundred fifty characters but there is a solution which implies adding a registry key and configuring the project to include a manifest
$ ninja
ninja: error: loading 'build.ninja': The system cannot find the path specified.

to this error message:

c:\Projects\C++\this is a rather long path for a path on windows where long paths are a problem with the limit of two hundred fifty characters but there is a solution which implies adding a registry key and configuring the project to include a manifest
$ ninja
ninja: error: build.ninja:1: expected '=', got newline
meh
   ^ near here

@jhasse
Copy link
Collaborator

jhasse commented Dec 13, 2022

wait a minute ... wasn't this supposed to only work with the unicode WinAPI functions ending with W? We're using the *A functions. I remember testing this a few years ago and it didn't have any effect. Has something changed?

@jhasse jhasse added the windows label Dec 13, 2022
@cristianadam
Copy link
Contributor Author

wait a minute ... wasn't this supposed to only work with the unicode WinAPI functions ending with W? We're using the *A functions. I remember testing this a few years ago and it didn't have any effect. Has something changed?

Above you have my test case. With the manifest entry and the registry key ninja was able to read the build.ninja file. Without it failed to find the file.

The same thing works also for MinGW GCC https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107974
Visual C++ doesn't like it, as seen at https://developercommunity.visualstudio.com/t/compiler-cant-find-source-file-in-path/10221576

Ninja is the missing part from having a working setup with GCC or Clang on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should support filename longer than 260 characters
2 participants