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

Symlink woes #6

Closed
kobaltz opened this issue Apr 7, 2016 · 30 comments
Closed

Symlink woes #6

kobaltz opened this issue Apr 7, 2016 · 30 comments

Comments

@kobaltz
Copy link

kobaltz commented Apr 7, 2016

While I understand that NTFS does not support Symlinks, it is something that would be extremely helpful. The issue that i've found is that any tarball package that has symlinks will simply be broken in the sense that the link is never created. Granted that packages/installers should be able to work around this, but I've already come across this issue within hours of playing around. I can see this causing several issues down the road.

Think of an installer that installs something to /opt/software but creates a symlink to the executable to /usr/local/bin so it would be ready for use immediately without explicitly specifying the path.

@mike-morr
Copy link

NTFS has supported symlinks since Windows 2000. NTFS Junction Point

@jokeyrhyme
Copy link

Related to #3 and/or #9 ?

@robertsmieja
Copy link

Look under "Is there any distinction between files in the Linux drive and the mounted Windows drives?" at https://msdn.microsoft.com/en-us/commandline/wsl/faq

I don't believe they intend for Linux symlinks to be able to point to Windows, but Linux symlinks from the Linux filesystem to the Linux filesystem should be fine.

@denisw
Copy link

denisw commented Apr 7, 2016

The inability to have symlinks between the Linux and Windows filesystems is unfortunate. For instance, this means that you cannot create a Python virtual environment on a Windows drive because that requires the venv tool to symlink /usr/bin/python and other stuff into the environment directory. It would be great if this restriction could somehow be relaxed!

More serious, though, is not being able to create symlinks within the Windows mount. Even when running Bash as an administrator, I wasn't able to create, a symlink /mnt/c/bar.txt to a file /mnt/c/foo.txt. This is absolutely required for installing many Node packages via NPM, for instance.

@mike-morr
Copy link

I just created a symlink from ~/home -> /mnt/c/Users/tellm and it worked fine.

image

@denisw
Copy link

denisw commented Apr 7, 2016

This direction (symlink from Linux to Windows) indeed works - the other one (symlink from Windows to Linux) doesn't.

@poizan42
Copy link

poizan42 commented Apr 7, 2016

There may be a bit of a problem with that since users on Windows by default don't have SeCreateSymbolicLinkPrivilege. As I understand this was done because as lots of applications and maybe even device drivers out there may have subtle security issues with symbolic links.

Requiring users to hold a certain privilege to create symlinks doesn't goes well with posix compatibility either.

@spichardo
Copy link

The issue with symlinks happens when you either try to tar to directory with symlinks or untar that contains them, look the simple example:

root@localhost:# mkdir test
root@localhost:
# cd test
root@localhost:/test# echo "this is a file" > t.xt
root@localhost:
/test# ln -s t.xt link_to_file
root@localhost:/test# ls -l
total 0
lrwxrwxrwx 1 root root 4 Apr 7 23:43 link_to_file -> t.xt
-rw-rw-rw- 1 root root 15 Apr 7 23:43 t.xt
root@localhost:
/test# cd ..
root@localhost:~# tar cfz test.gz test/
tar: test/link_to_file: Cannot readlink: Invalid argument
tar: Exiting with failure status due to previous errors

@spichardo
Copy link

and this is also related to #50

@tinysun212
Copy link

pointed the same thing to #9

@hacst
Copy link

hacst commented Apr 9, 2016

What @poizan42 mentioned about permissions is exacerbated by the fact that - as far as I understand split tokens in UAC - non-elevated processes of users in admin groups (it's RID based, msdn has the details) can never have that privilege. Even if you edit the group policy to add it for everyone that just gets filtered out with no way to override it. Imho this is a major pita and it has bitten me outside of this specific issue. It makes using symlinks on dev setups (whose accounts tend to have admin rights) nearly impossible. Basically you can make it work for the Guest account but not without elevation for an admin :( Would love to see that resolved.

@JonHerr
Copy link

JonHerr commented Apr 11, 2016

I will add to the symlink issue. I tried to install NVM (node version manager) and RVM (ruby version manager) I ran into issues with cannot create symlink to "" Invalid argument. these tools are essential as working with multiple products I need to be able to easily change which verion of node and ruby I am using.

@MadcowD
Copy link

MadcowD commented Apr 12, 2016

This issue has been closed #9 @bitcrazed please closed this #6

@russalex
Copy link
Contributor

Wanted to update this one since it's one of our oldest threads.

We have much better symlink support checked into our dev branches. No ETA on when it will hit Insiders, and I expect that the support will roll out slowly (we did not fix all the issues at once). What I can show is what ran on an internal branch:

russ@RUSSALEX-DESK:/mnt/d/temp$ touch file
russ@RUSSALEX-DESK:/mnt/d/temp$ ln -s file filelink
russ@RUSSALEX-DESK:/mnt/d/temp$ ln -s ~ home
russ@RUSSALEX-DESK:/mnt/d/temp$ ll
total 4
drwxrwxrwx 2 root root  0 Apr 19 23:33 ./
drwxrwxrwx 2 root root  0 Apr 19 20:17 ../
-rwxrwxrwx 1 root root  0 Apr 19 23:33 file*
lrwxrwxrwx 1 root root  4 Apr 19 23:33 filelink -> file*
lrwxrwxrwx 1 root root 10 Apr 19 23:33 home -> /home/russ/
russ@RUSSALEX-DESK:/mnt/d/temp$ cd home
russ@RUSSALEX-DESK:/mnt/d/temp/home$ ll
total 24
drwxr-xr-x 2 russ russ    0 Apr 19 19:34 ./
drwxr-xr-x 2 root root    0 Jan  1  1970 ../
-rw------- 1 russ russ 2043 Apr 19 23:03 .bash_history
-rw-r--r-- 1 russ russ  220 Apr 18 18:40 .bash_logout
-rw-r--r-- 1 russ russ 3636 Apr 18 18:41 .bashrc
lrwxrwxrwx 1 russ russ    4 Apr 19 23:32 home -> home
-rw-r--r-- 1 russ russ  675 Apr 18 18:40 .profile
drwxrwxrwx 2 russ russ    0 Apr 19 22:53 tmp/
-rw------- 1 russ russ 1159 Apr 18 18:43 .viminfo

@denisw
Copy link

denisw commented Apr 20, 2016

Awesome! That is pretty much the missing link (pun intended) to make Bash on Windows work for me. Looking forward to seeing these changes in future Insider builds!

@sunilmut
Copy link
Member

symlink improvements were made in the new Windows build 14328, WSL specific release notes are here
If this build resolves the issue, we would like to close this out.

@hacst
Copy link

hacst commented Apr 22, 2016

Awesome work. Could you talk a bit about how this is implemented technically? Are those symlinks backed by NTFS or something special to WSL? In case of the former I would love to know how the permissions are handled w.r.t SeCreateSymbolicLinkPrivilege and dual/split tokens in admin accounts.

@russalex
Copy link
Contributor

@hacst, We have a few more blog posts in the works with one of them being a deep dive into the filesystem. Stay tuned.

To answer your immediate question, these symlinks are not backed by NTFS.

I'll be closing this issue out soon to keep things clean.

@drvink
Copy link

drvink commented Jun 2, 2016

This is only barely related, but it has been a thorn in my (and many, many others) side for years, and I don't know where else to bring it up, but: since we're now getting sane symlink behavior in one Windows subsystem, can we please, please, please for the love of god, finally correct the behavior in which UAC removes SeCreateSymbolicLinkPrivilege from users' tokens if they're in the Administrators group, even if they've explicitly been given the privilege in some other way? Remember, this insane behavior is ONLY applied to members of the Administrators group--if you give a normal user account permission to create symlinks, they can do it just fine, with no need to elevate!

@russalex
Copy link
Contributor

russalex commented Jun 2, 2016

@drvink, I feel your pain here and have forwarded this along to the correct team.

Additionally, you should start something over on our User Voice. We have a number of symlink suggestions over there but they are all around WSL. Getting this as a separate item may be helpful.

@drvink
Copy link

drvink commented Jun 3, 2016

@russalex, this is wonderful to hear. Thank you so much! I'll add a UV suggestion too.

@jan4984
Copy link

jan4984 commented Nov 19, 2018

I have a removable ntfs driver, it worked in a ubuntu, on which symbolic links created. now when I connect the ntfs driver to windows and wsl, the links all not work.

is any way keep my links between ubuntu and wsl?

@cavaunpeu
Copy link

$ cd /mnt/c/foo
$ echo "bar" > baz
$ ln -s baz bazlink

...Open Powershell...

$ PS C:\foo> cat bazlink
bar

However, when I:

$ cd ~
$ echo "pickles" > skittles
$ cd /mnt/c/foo
$ ln -s ~/skittles skittleslink

...Open Powershell...

$ PS C:\foo> cat .\skittleslink
cat : The file cannot be accessed by the system.
At line:1 char:1
+ cat .\skittleslink
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ReadError: (C:\foo\skittleslink:String) [Get-Content], IOException
    + FullyQualifiedErrorId : GetContentReaderIOError,Microsoft.PowerShell.Commands.GetContentCommand

@Macmee Macmee mentioned this issue Aug 22, 2022
2 tasks
@DynConcepts
Copy link

russ@RUSSALEX-DESK:/mnt/d/temp$ touch file
russ@RUSSALEX-DESK:/mnt/d/temp$ ln -s file filelink
russ@RUSSALEX-DESK:/mnt/d/temp$ ln -s ~ home
russ@RUSSALEX-DESK:/mnt/d/temp$ ll
total 4
drwxrwxrwx 2 root root  0 Apr 19 23:33 ./
drwxrwxrwx 2 root root  0 Apr 19 20:17 ../
-rwxrwxrwx 1 root root  0 Apr 19 23:33 file*
lrwxrwxrwx 1 root root  4 Apr 19 23:33 filelink -> file*
lrwxrwxrwx 1 root root 10 Apr 19 23:33 home -> /home/russ/
russ@RUSSALEX-DESK:/mnt/d/temp$ cd home
russ@RUSSALEX-DESK:/mnt/d/temp/home$ ll
total 24
drwxr-xr-x 2 russ russ    0 Apr 19 19:34 ./
drwxr-xr-x 2 root root    0 Jan  1  1970 ../
-rw------- 1 russ russ 2043 Apr 19 23:03 .bash_history
-rw-r--r-- 1 russ russ  220 Apr 18 18:40 .bash_logout
-rw-r--r-- 1 russ russ 3636 Apr 18 18:41 .bashrc
lrwxrwxrwx 1 russ russ    4 Apr 19 23:32 home -> home
-rw-r--r-- 1 russ russ  675 Apr 18 18:40 .profile
drwxrwxrwx 2 russ russ    0 Apr 19 22:53 tmp/
-rw------- 1 russ russ 1159 Apr 18 18:43 .viminfo

Yes, but now exit WSL [or simply open a CMD prompt window and go to D:\temp and try to access things....

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