msys2-runtime icon indicating copy to clipboard operation
msys2-runtime copied to clipboard

Symbolic link to directory creation fails because of too long paths even if path <= 260 characters

Open Joshua-Schroijen opened this issue 1 year ago • 1 comments

Hello!

I have noticed a strange issue with using ln -s inside of MSYS2 which I'm inclined to consider a bug. Even after I enabled long paths inside of the Windows registry ln -s will complain about paths being too long to symlink to and will exit with an error code of 1 when creating symlinks to directories. The strange thing is that this also happens when the paths are far less than 260 characters long. If the paths are short enough, the symlink will be created regardless of the error. If the path is longer than 260 characters, the symlink will not be created.

Steps to reproduce

Run the following commands inside of MSYS2 after enabling long paths in the Windows registry and rebooting:

mkdir -p /c/foo
cd /c/foo
ln -s .. bar
mkdir -p /c/betts/underscores/aiding/elegance/arginine/turkmen/ballet/bumsen/bendigo/steam/chronically/kannur/source/stalled/mangled/toolkit/strength/fateful/kurosawa/effectiveness/yardage/newport/repairers/prawn/angela/resembles/projekt/avalanche/storedge/alibi/gauteng/chaim/estudio/zante/thickened/retention/wieder/pretzel/maastricht/speciality/universalist/heine/nagios/spans/meetup/binders/strict/tooltip/beastiality/terrace  
cd /c/betts/underscores/aiding/elegance/arginine/turkmen/ballet/bumsen/bendigo/steam/chronically/kannur/source/stalled/mangled/toolkit/strength/fateful/kurosawa/effectiveness/yardage/newport/repairers/prawn/angela/resembles/projekt/avalanche/storedge/alibi/gauteng/chaim/estudio/zante/thickened/retention/wieder/pretzel/maastricht/speciality/universalist/heine/nagios/spans/meetup/binders/strict/tooltip/beastiality/terrace  
ln -s .. foo

MSYS2 Version

uname -a for my MSYS2 installation:

MSYS_NT-10.0-19045 ___________ 3.5.3.x86_64 2024-05-06 06:45 UTC x86_64 Msys

Implications

This bug can cause many kinds of frustrating problems because many shell scripts and tools like tar often need to create symlinks to other directories

I thank you in advance for investigating this bug!

Joshua-Schroijen avatar May 25 '24 16:05 Joshua-Schroijen

On MSYS2 v3.4.10 the latter symlink gets created:

saukrs@DESKTOP-O7JE7JE MSYS /c/betts/underscores/aiding/elegance/arginine/turkmen/ballet/bumsen/bendigo/steam/chronically/kannur/source/stalled/mangled/toolkit/strength/fateful/kurosawa/effectiveness/yardage/newport/repairers/prawn/angela/resembles/projekt/avalanche/storedge/alibi/gauteng/chaim/estudio/zante/thickened/retention/wieder/pretzel/maastricht/speciality/universalist/heine/nagios/spans/meetup/binders/strict/tooltip/beastiality/terrace
$ ll foo
lrwxrwxrwx 1 saukrs None 17 May 25 19:43 foo -> ../../beastiality

... but its' content is quite strange: instead of .. it points to ../../beastiality which logically is the same.

At least that's happening on my setup:

saukrs@DESKTOP-O7JE7JE MSYS /c/foo
$ uname -a
MSYS_NT-10.0-19044 DESKTOP-O7JE7JE 3.4.10.x86_64 2023-12-22 10:06 UTC x86_64 Msys

saukrs@DESKTOP-O7JE7JE MSYS /c/foo
$ echo $MSYS
winsymlinks:nativestrict

Cygwin 3.4.10 works as expected:

saukrs@DESKTOP-O7JE7JE /cygdrive/c/betts/underscores/aiding/elegance/arginine/turkmen/ballet/bumsen/bendigo/steam/chronically/kannur/source/stalled/mangled/toolkit/strength/fateful/kurosawa/effectiveness/yardage/newport/repairers/prawn/angela/resembles/projekt/avalanche/storedge/alibi/gauteng/chaim/estudio/zante/thickened/retention/wieder/pretzel/maastricht/speciality/universalist/heine/nagios/spans/meetup/binders/strict/tooltip/beastiality/terrace
$ ln -sv .. foo
'foo' -> '..'

saukrs@DESKTOP-O7JE7JE /cygdrive/c/betts/underscores/aiding/elegance/arginine/turkmen/ballet/bumsen/bendigo/steam/chronically/kannur/source/stalled/mangled/toolkit/strength/fateful/kurosawa/effectiveness/yardage/newport/repairers/prawn/angela/resembles/projekt/avalanche/storedge/alibi/gauteng/chaim/estudio/zante/thickened/retention/wieder/pretzel/maastricht/speciality/universalist/heine/nagios/spans/meetup/binders/strict/tooltip/beastiality/terrace
$ ll foo
lrwxrwxrwx 1 saukrs None 2 May 25 20:04 foo -> ..

saukrs@DESKTOP-O7JE7JE /cygdrive/c/betts/underscores/aiding/elegance/arginine/turkmen/ballet/bumsen/bendigo/steam/chronically/kannur/source/stalled/mangled/toolkit/strength/fateful/kurosawa/effectiveness/yardage/newport/repairers/prawn/angela/resembles/projekt/avalanche/storedge/alibi/gauteng/chaim/estudio/zante/thickened/retention/wieder/pretzel/maastricht/speciality/universalist/heine/nagios/spans/meetup/binders/strict/tooltip/beastiality/terrace
$ uname -a
CYGWIN_NT-10.0-19044 DESKTOP-O7JE7JE 3.4.10-1.x86_64 2023-11-29 12:12 UTC x86_64 Cygwin

sskras avatar May 25 '24 16:05 sskras