-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
FileManager.enumerator(at:)
stops iterating upon seeing path that exceeds MAX_PATH
on Windows
#5135
Comments
It appears that moving the index-build directory to be a subdirectory of `.build` caused some file in the index-build directory to exceed the `MAX_PATH` length on the SourceKit-LSP PR testing job (but not the swift PR job because that has a shorter job name). Because of https://github.com/swiftlang/swift-foundation/issues/1049, we would stop directory iteration at that file exceeding `MAX_PATH` and never find `MyDependency.swift`, causing these tests to fail.
It appears that moving the index-build directory to be a subdirectory of `.build` caused some file in the index-build directory to exceed the `MAX_PATH` length on the SourceKit-LSP PR testing job (but not the swift PR job because that has a shorter job name). Because of https://github.com/swiftlang/swift-foundation/issues/1049, we would stop directory iteration at that file exceeding `MAX_PATH` and never find `MyDependency.swift`, causing these tests to fail.
@ahoppen the reason that enumeration stops here is because an error has occurred. In particular, the error is:
I suspect some API which we are calling is not handling the long paths well. The documentation states that, for the error handler parameter:
However it seems like on Windows that behavior is the opposite: swift-corelibs-foundation/Sources/Foundation/FileManager+Win32.swift Lines 326 to 329 in 21b3196
So I agree it seems like there's two problems here:
For now if you need to work around issue number 1, you can provide a custom error handler which returns |
Oh, great. Thanks for the detailed analysis. We’re not seeing any long path related issues right now because I shortened all paths sufficiently but I’ll use that workaround when we see an issue next time. |
The first part of the issue (the default error handler behavior on Windows) will be resolved by #5136 |
Thanks for the fix @jmschonfeld. That was the issue that bogged me more than skipping directories that exceed |
Run the following to create a file at a path that exceeds
MAXPATH
Now run
Notice how it outputs
Directory iteration stops upon reaching the
eeeee…txt
file that exceedsMAX_PATH
anda.txt
is never printed. I would expect directory iteration to eitherbut not to stop iteration upon reaching the first file that exceeds the maximum path length altogether.
The text was updated successfully, but these errors were encountered: