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

Windows 11: Failed test 'relative symlinks with updir' at t/symlinks.t line 31. #271

Open
hakonhagland opened this issue Nov 19, 2022 · 1 comment

Comments

@hakonhagland
Copy link

I am trying to install Path::Tiny on Windows 11 using a debug version of perl 5.37.6 using MinGW-w64 and gcc 11.3.0 from https://winlibs.com/ (using the MSVCRT runtime library), more information here: Perl/perl5#20395.

When testing Path::Tiny including both the fix in #268 for realpath and the fix in #269 for lstat->size, I get:

>gmake test
"C:\perl-debug\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t/*.t
t/basename.t ...................... ok
t/basic.t ......................... ok
t/children.t ...................... ok
t/chmod.t ......................... ok
t/digest.t ........................ ok
t/exception.t ..................... ok
t/exports.t ....................... ok
t/filesystem.t .................... ok
t/has_same_bytes.t ................ ok

[...]

t/size.t .......................... ok
t/subsumes.t ...................... ok
t/symlinks.t ......................
    #   Failed test 'abs_path gets's it right'
    #   at t/symlinks.t line 28.
    #          got: undef
    #     expected: 'C:/Users/hakon/AppData/Local/Temp/9C5IA3G3mi/tmp/foo'
    # Looks like you failed 1 test of 5.
t/symlinks.t ...................... 1/?
#   Failed test 'relative symlinks with updir'
#   at t/symlinks.t line 31.
# Looks like you failed 1 test of 2.
t/symlinks.t ...................... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests
t/temp.t .......................... ok

[...]

More information about the failed test:

>perl -Ilib t\symlinks.t
# Subtest: relative symlinks with updir
    ok 1 - it's a file
    ok 2 - it's a link
    ok 3 - the link seems right
    not ok 4 - abs_path gets's it right
    #   Failed test 'abs_path gets's it right'
    #   at t\symlinks.t line 28.
    #          got: undef
    #     expected: 'C:/Users/hakon/AppData/Local/Temp/oii4Dv_WlF/tmp/foo'
    ok 5 - realpath get's it right
    1..5
    # Looks like you failed 1 test of 5.
not ok 1 - relative symlinks with updir
#   Failed test 'relative symlinks with updir'
#   at t\symlinks.t line 31.
# Subtest: symlink loop detection
    ok 1 - symlink loop detected
    1..1
ok 2 - symlink loop detection
1..2
# Looks like you failed 1 test of 2.

The problem seems to be a bug in Win32 API for CreateFileA() when a target of a symlink contains a relative path with forward slashes (as opposed to backward slashes) it fails. A fix has been suggested in Perl5/blead, see Perl/perl5#20506 for more information.

@hakonhagland
Copy link
Author

Added a PR to fix this for now, see #272

hakonhagland added a commit to hakonhagland/Path-Tiny that referenced this issue Nov 20, 2022
Don't use forward slashes in a relative symlink target on Windows.
For more information see issue dagolden#271.

This fixes issue dagolden#273.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant