You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WSL treating symlinks as win32 junction (redux) #4868
Looks like this was brought up in October 2019, but no one inc myself would notice in a long closed issue.
What's wrong / what should be happening instead:
Regress #353 (message). They were win32 symlinks (contrast junctions) as of 17046, as long as the user possesses SE_CREATE_SYMBOLIC_LINK_PRIVILEGE, which (quoth) "normally requires you to launch wsl.exe elevated), unless Developer Mode is turned on."
It is possible the definition of "developer mode" changed somewhere along the lines.
Strace of the failing command
The syscalls succeed, natch.
Reacted by Kyle J Strand, Hayden Barnes, Andrew Watkins, Scott Gammill, Sean Pivek, Maxime Meriouma-Caron, Ali Chaudry, Ott, Savvy Raghuvanshi, Bryan Murphy and 9 more
Reacted by Kyle J Strand, Sean Pivek, Savvy Raghuvanshi, Donal Hunt and standardizer
It is possible the definition of "developer mode" changed somewhere along the lines.
Setting aside "Developer Mode", it might be possible we've lost "launch wsl.exe elevated" around the time WSL2 was released to Insiders. If WSL is started (invoked while in the stopped state) from an Admin cmd.exe, symlinks also appear as junctions on the win32 side. [Will spare the screencap, it looks the same.]
If this theory is correct, then some other elevated WSL1 functionality went down with it (CLONE_NEWNET ref #3282 (message) comes to mind). Need more investigation to confirm if this is the case.
I'm not sure that I'm adding much to this conversation, but I just wanted to note that we are running into this when cloning a git repo inside of Ubuntu. This repo contains some symlinks, and these symlinks are not readable by the Windows side of things. This means that git on the Windows side of things gives all sorts of errors like:
> git diff --summary
some_symlink: Function not implemented
another_symlink: Function not implemented
In addition, there are plenty of Input/Output errors when trying to read said files from the windows side of things:
> type '\\wsl$\Ubuntu-18.04\home\taytay\some_symlink'
type : The name of the file cannot be resolved by the system.
At line:1 char:1
+ type '\\wsl$\Ubuntu-18.04\home\taytay\some_symlink ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ReadError: (\\wsl$\Ubuntu-1...some_symlink:String) [Get-Content], IOException
+ FullyQualifiedErrorId : GetContentReaderIOError,Microsoft.PowerShell.Commands.GetContentCommand
My ideal is to do 99% of my work from the Linux side of things, but use some Windows Git GUI tools to manage these Git repos, and this sort of mismatch is throwing a wrench in those plans.
I'm including some of the above in hopes that googling for WSL, "Function not implemented", git, and WSL might turn up this issue, which took me a while to find. :)
Ran into something similar while debugging intellij-rust/intellij-rust#1171. In this case, Java totally fails to read the symlink on the WSL fs. I originally thought this might just be an upstream bug in openjdk, but it appears that there is weird behavior on the Windows side:
I've barely used Windows, so apologies if I misunderstand how symlinks work on the platform, but it looks to me like the file attributes correctly recognize that this is a symlink, but all the metadata is null. I imagine Java is using this and thus thinks the file doesn't exist / is unable to follow the link.
This does not work also for symlinks created on drvfs. I use WSL2 with home directory redirected to /mnt/C/Users/my_windows_user (it's slow but I need that).
When I create symlink inside WSL with ln -s /home/a b where a is directory, on Windows side (e.g. in cmd.exe) it shows as 04/07/2022 09:49 PM <JUNCTION> b [...] and it is not accessible from explorer.exe (gives an error C:\Users\my_windows_user\b is not accesible). When link is relative Windows explorer.exe shows icon as directory with link overlay while if link is absolute (still pointing from drvfs to drvfs) it shows as unknown file even if it's a directory.
I've had this problem since I started with WSL and thought it was just always broken.
But, after reading #353 #2144
I realised that it worked for some and not for others and it's been like that for a while.
And noting some config differences, I managed to fix it (on my systems, anyway). Let me know what does/does not work for you and what incorrect assumptions and/or conclusions I am making.
So:
Turns out the trick is to mount C: with metadata and via drvfs+bind rather than the default, whatever that is? SMB??
Before doing ln -s in WSL created a symlink that had the l flag in Windows but says something like "Can not locate file"
And doing New-Item -type symlink in Windows made a regular file in WSL that was 0 bytes, so not a symlink or dir.
After this small change, New-Item and ln -s both work across platforms!! Very happy :)
NOTE 1: I did this with latest WSL2, a stock Ubuntu 22.04 distribution in Win10 Enterprise
NOTE 2: I don't think this works when the link source and target are on different filesystems. So (sadly) you can't link from e.g. /home/me to /mnt/c/users/me or the other way round, as those are different file systems. But (now, for me) link soure+targets that are created under /mnt/c/... from either OS will be correct for both Windows and Linux.
NOTE 3: It seems that I can't browse \\wsl$\c\... or \\wsl.local\c\... as I get permission error. I don't know the implications of that....
Here is what I did to get symlinks working.
btw: Is it me, or after changing the mounts do I notice that WSL is significantly faster listing folders etc.?
Edit /etc/wsl.conf
(for me no changes, but posted as perhaps your's is not the same)
Tried to reproduce Jay's (Jay (@the-moog)) encouraging result, but no luck. Or, "not enough" luck: links created on Windows (10) work fine on the WSL side (Debian 12) [actually, I can't remember now whether they always worked...], but whatever I do in Linux (incl. copying existing ones created by Windows etc.), those links are just still incompatible with Windows. :-/
FTR:
$ mount -v | grep mnt/c
drvfs on /mnt/c-interop type 9p (rw,noatime,dirsync,aname=drvfs;path=C:;metadata;uid=1000;gid=1000;u
mask=022;fmask=011;symlinkroot=/mnt/,mmap,access=client,msize=262144,trans=virtio)
drvfs on /mnt/c type 9p (rw,noatime,dirsync,aname=drvfs;path=C:;metadata;uid=1000;gid=1000;umask=022
;fmask=011;symlinkroot=/mnt/,mmap,access=client,msize=262144,trans=virtio)
I haven't added the systemd entry to my wsl.conf, but that should make no difference.
BTW, I also noticed some speed increase, but only a marginal one: 16s for a find . >/dev/null as opposed to 18s (over 3 consecutive runs), FWIW. But I don't know what that "listing folders" really meant, so this may be irrelevant to Jay's remark.
Also, a possibly related SE/su comment:
Creation of reparse point-based symlinks was implemented in ntfs-3g two weeks ago. Though it uses the WSL-specific reparse tag, not the native Windows 7–10 symlinks (possibly because those don't exactly match Linux semantics). – u1686_grawity, Feb 8, 2021 at 20:13
This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.
Activity
therealkenc commentedon Feb 25, 2020
Setting aside "Developer Mode", it might be possible we've lost "launch wsl.exe elevated" around the time WSL2 was released to Insiders. If WSL is started (invoked while in the stopped state) from an Admin
cmd.exe, symlinks also appear as junctions on the win32 side. [Will spare the screencap, it looks the same.]If this theory is correct, then some other elevated WSL1 functionality went down with it (
CLONE_NEWNETref #3282 (message) comes to mind). Need more investigation to confirm if this is the case.Taytay commentedon Oct 7, 2020
I'm not sure that I'm adding much to this conversation, but I just wanted to note that we are running into this when cloning a git repo inside of Ubuntu. This repo contains some symlinks, and these symlinks are not readable by the Windows side of things. This means that git on the Windows side of things gives all sorts of errors like:
In addition, there are plenty of Input/Output errors when trying to read said files from the windows side of things:
My ideal is to do 99% of my work from the Linux side of things, but use some Windows Git GUI tools to manage these Git repos, and this sort of mismatch is throwing a wrench in those plans.
I'm including some of the above in hopes that googling for WSL, "Function not implemented", git, and WSL might turn up this issue, which took me a while to find. :)
tychedelia commentedon May 28, 2021
Ran into something similar while debugging intellij-rust/intellij-rust#1171. In this case, Java totally fails to read the symlink on the WSL fs. I originally thought this might just be an upstream bug in openjdk, but it appears that there is weird behavior on the Windows side:
I've barely used Windows, so apologies if I misunderstand how symlinks work on the platform, but it looks to me like the file attributes correctly recognize that this is a symlink, but all the metadata is null. I imagine Java is using this and thus thinks the file doesn't exist / is unable to follow the link.
PrasadTamgale commentedon Oct 8, 2021
Try these workarounds until this issue is patched.
\\localhost\<share>which also resolves the symlinks.donalhunt commentedon Oct 11, 2021
my issue regarding file permissions under linux changing seems to be due to DrvFS having metadata turned off by default. 🙄
xmontero commentedon Dec 24, 2021
Is this question https://superuser.com/q/1695779/324451 the same than this bug?
blami commentedon Apr 7, 2022
This does not work also for symlinks created on drvfs. I use WSL2 with home directory redirected to /mnt/C/Users/my_windows_user (it's slow but I need that).
When I create symlink inside WSL with
ln -s /home/a bwhere a is directory, on Windows side (e.g. in cmd.exe) it shows as04/07/2022 09:49 PM <JUNCTION> b [...]and it is not accessible from explorer.exe (gives an error C:\Users\my_windows_user\b is not accesible). When link is relative Windows explorer.exe shows icon as directory with link overlay while if link is absolute (still pointing from drvfs to drvfs) it shows as unknown file even if it's a directory.audrenbdb commentedon May 12, 2022
+1
the-moog commentedon Mar 14, 2023
I've had this problem since I started with WSL and thought it was just always broken.
But, after reading
#353
#2144
I realised that it worked for some and not for others and it's been like that for a while.
And noting some config differences, I managed to fix it (on my systems, anyway). Let me know what does/does not work for you and what incorrect assumptions and/or conclusions I am making.
So:
Turns out the trick is to mount C: with metadata and via drvfs+bind rather than the default, whatever that is? SMB??
Before doing
ln -sin WSL created a symlink that had thelflag in Windows but says something like "Can not locate file"And doing New-Item -type symlink in Windows made a regular file in WSL that was 0 bytes, so not a symlink or dir.
After this small change, New-Item and ln -s both work across platforms!! Very happy :)
NOTE 1: I did this with latest WSL2, a stock Ubuntu 22.04 distribution in Win10 Enterprise
NOTE 2: I don't think this works when the link source and target are on different filesystems. So (sadly) you can't link from e.g.
/home/meto/mnt/c/users/meor the other way round, as those are different file systems. But (now, for me) link soure+targets that are created under /mnt/c/... from either OS will be correct for both Windows and Linux.NOTE 3: It seems that I can't browse
\\wsl$\c\...or\\wsl.local\c\...as I get permission error. I don't know the implications of that....Here is what I did to get symlinks working.
btw: Is it me, or after changing the mounts do I notice that WSL is significantly faster listing folders etc.?
Edit
/etc/wsl.conf(for me no changes, but posted as perhaps your's is not the same)
Edit
/etc/fstabThe 2nd two lines were added, the first line is just the root file system for WSL
Create a folder
/mnt/c_driveto receive the mountCheck my
C:\Users\%USER%\.wslconfigReboot wsl using
wsl --shutdownNow
/mnt/cpoints toC:\(as does/mnt/c_drive).I don't think you can use bind mounts with
C:, hence the two mount steps.xparq commentedon Aug 23, 2023
Tried to reproduce Jay's (Jay (@the-moog)) encouraging result, but no luck. Or, "not enough" luck: links created on Windows (10) work fine on the WSL side (Debian 12) [actually, I can't remember now whether they always worked...], but whatever I do in Linux (incl. copying existing ones created by Windows etc.), those links are just still incompatible with Windows. :-/
FTR:
systemdentry to mywsl.conf, but that should make no difference.find . >/dev/nullas opposed to 18s (over 3 consecutive runs), FWIW. But I don't know what that "listing folders" really meant, so this may be irrelevant to Jay's remark.Also, a possibly related SE/su comment:
microsoft-github-policy-service commentedon Aug 29, 2024
This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.
Thank you!