-
Notifications
You must be signed in to change notification settings - Fork 532
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
Forward slashes not recognized in relative symlink targets on Windows #20506
Comments
Could this be the problem? See line 1749 in win32.c:
When I set a breakpoint here in gdb I see that So we cannot have a symlink with a path with backward slashes, at the same time as its target uses forward slashes? |
Looking closer, it seems like this may not be the problem after all. Maybe rather line 1811 in win32.c?
In gdb I see that |
I can't find any issue with CreateFileA() and backslash v forwardslash. According to the attached Inline::C demo, CreateFileA will return CreateFileA will also return But I can't find any evidence that either forwardslashes or backslashes (or a mixture of both) have any bearing on the behaviour. I've tested the script on both 5.36.0 and 5.37.5 (latest devel release). Cheers, |
I've reproduced the behaviour. From what I can tell the problem is windows, if I stop your test code in the middle, with the symlink created:
The CreateFileA() call for the symlink has failed, the behaviour of follow_symlinks_to() is irrelevant - the following should only be needed for symlink chains that end in a special file, such as a AF_UNIX socket. The fix is probably for win32_symlink() to replace any |
Windows, or at least NTFS, doesn't appear to follow symlinks where the target contains the POSIX directory separator "/". To fix that translate any / to \ in symlink targets. This may break code that checks the symlink target macthes a value set, but I think it's more likely to fix code that blindly uses / than break code that looks at the symlink target they just set. Fixes Perl#20506
@tonycoz Yes that seems like a good idea! Let me know if I should do any further testing.
@sisyphus From the perl script you linked to, is it correct that |
Yeah, that's correct. On both Windows 11 and Windows 7, I have not been able to build a perl (including blead) that supports symlinks. Thank you, @hakonhagland, for giving me the opportunity to clarify ;-) Cheers, |
Under Windows 7 it should work with an administrative/elevated shell. For Windows 11 you need either an elevated shell, or to enable developer mode in control panel. For either mklink (the command-line tool) or perl's symlink() should work. |
@sisyphus Yes, I forgot to mention that I had turned on "Developer mode" on Windows 11. (Go to the Windows settings app and choose "Update & Security" -> "For developers", and turn on "Developer mode"). |
Yep - got it. Running in an elevated shell on 11, or as Administrator on 7 is sufficient to enable symlinks for me. Cheers, |
Windows, or at least NTFS, doesn't appear to follow symlinks where the target contains the POSIX directory separator "/". To fix that translate any / to \ in symlink targets. This may break code that checks the symlink target macthes a value set, but I think it's more likely to fix code that blindly uses / than break code that looks at the symlink target they just set. Fixes Perl#20506
Windows, or at least NTFS, doesn't appear to follow symlinks where the target contains the POSIX directory separator "/". To fix that translate any / to \ in symlink targets. This may break code that checks the symlink target macthes a value set, but I think it's more likely to fix code that blindly uses / than break code that looks at the symlink target they just set. Fixes Perl#20506
Windows, or at least NTFS, doesn't appear to follow symlinks where the target contains the POSIX directory separator "/". To fix that translate any / to \ in symlink targets. This may break code that checks the symlink target macthes a value set, but I think it's more likely to fix code that blindly uses / than break code that looks at the symlink target they just set. Fixes #20506
Windows, or at least NTFS, doesn't appear to follow symlinks where the target contains the POSIX directory separator "/". To fix that translate any / to \ in symlink targets. This may break code that checks the symlink target macthes a value set, but I think it's more likely to fix code that blindly uses / than break code that looks at the symlink target they just set. Fixes Perl#20506
Windows, or at least NTFS, doesn't appear to follow symlinks where the target contains the POSIX directory separator "/". To fix that translate any / to \ in symlink targets. This may break code that checks the symlink target macthes a value set, but I think it's more likely to fix code that blindly uses / than break code that looks at the symlink target they just set. Fixes Perl#20506
Windows, or at least NTFS, doesn't appear to follow symlinks where the target contains the POSIX directory separator "/". To fix that translate any / to \ in symlink targets. This may break code that checks the symlink target macthes a value set, but I think it's more likely to fix code that blindly uses / than break code that looks at the symlink target they just set. Fixes Perl#20506
I have built a debug version of perl 5.37.6 on Windows 11 using MinGW-w64 and gcc 11.3.0 from https://winlibs.com/ (using the MSVCRT runtime library). Note that this includes #20271, which fixes the readlink behavior on Windows, see #20460 for more information.
When trying to install
Path::Tiny
using this perl I get a test failure due to-e
operator not working on a symlink. Here is a minimal example:The output is:
Expected output is:
Note that if I use backward slashes instead of forward slashes when defining the target on line 20, I get the expected output. Similarly, if I use an absolute path for the target (still with forward slashes), I also get the expected output.
Perl configuration
The text was updated successfully, but these errors were encountered: