-
Notifications
You must be signed in to change notification settings - Fork 559
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
File::Find: fix "follow => 1" on Windows #20008
Conversation
This commit doesn't contain any functional changes. If you're seeing it in "git blame" output, try using -w switch, it will hide whitespace-only changes.
File::Find's code expects unix-style paths and it manipulates them using basic string operations. That code is very fragile, and ideally we should make it use File::Spec, but that would involve rewriting almost the whole module. Instead, we made it convert backslashes to slashes and handle drive letters. Note from xenu: this commit was adapted from the PR linked in this blogpost[1]. I have squashed it, written the commit message and slightly modified the code. [1] - https://www.nu42.com/2021/09/canonical-paths-file-find-way-forward.html Fixes Perl#19995
Note for reviewers: one of the commits converts tabs to spaces, make sure to hide whitespace changes. |
This PR fixes the issue with Module::Pluggable. Thanks @xenu, for digging through all of that. The failing test script in Module::Find is t/07-symlinks.t.
On my Windows systems, with perl-5.32 (File-Find-1.37), $@ is set and all 13 tests are skipped - as is the correct thing to do, IIUC.
which is the behaviour that t/07-symlinks.t is checking for. Cheers, |
That check in Module::Find isn't quite what the docs say it should be, and should be changed IMO. |
But even if it strictly adheres to the docs, I still get different results between 5.32 and this PR. With perl-5.32:
With this PR:
IIU the symlink() docs correctly, we should be getting an exception in both cases - given that symlinks are unsupported on this system of mine. Cheers, |
The OS supports it, they're just not enabled. Hence symlink returns 0. |
The best ways to check if you have the required permissions to create a symlink on Windows are:
|
I have never used symlinks on Windows before, but I find I can create them on my Windows 10 machine (as Administrator). I did a basic test of File::Find using my Strawberrry Perl 5.32 and 5.36 installations, with File::Find 1.37 and 1.40 respectively. This is what I found:
It looks to me like the functionality is correct for 1.40. |
I noticed it too, which is why this PR removes it :) |
Ok - If no-one beats me to it, I'll update crenz/Module-Find#9 accordingly. Cheers, |
That's also the version where support for symlinks was introduced. Basically, when you're on Windows and
|
Can/will this fix be backported to future 5.34.x and 5.36.x releases ? |
0.16, 2022-08-01 Fixes an issue where symlink tests failed on systems that do not support creation of symlinks. The issue appears on Windows systems due to changed behaviour in "File::Find" described in perl5/issue #19995 <Perl/perl5#19995> Symlink tests were previously skipped if symlink() is not available, and now also if creation of a symlink is not possible. Fixes issue #9 <crenz/Module-Find#9>. Note that on Windows system, the patch to "File::Find" from perl5/PR #20008 <Perl/perl5#20008> will be required for proper operation.
File::Find's code expects unix-style paths and it manipulates them using
basic string operations. That code is very fragile, and ideally we
should make it use File::Spec, but that would involve rewriting almost
the whole module.
Instead, we made it convert backslashes to slashes and handle drive
letters.
Note from xenu: this commit was adapted from the PR linked in this
blogpost[1]. I have squashed it, written the commit message and slightly
modified the code.
[1] - https://www.nu42.com/2021/09/canonical-paths-file-find-way-forward.html
Fixes #19995