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

access Linux symlinks from \\wsl$ #5118

Open
trentis opened this issue Apr 21, 2020 · 125 comments
Open

access Linux symlinks from \\wsl$ #5118

trentis opened this issue Apr 21, 2020 · 125 comments

Comments

@trentis
Copy link

trentis commented Apr 21, 2020

Is your feature request related to a problem? Please describe.
I want to be able to open a symlink from the '\wsl$\Ubuntu' directory. The reason for this Is I'm writing a program that would read an elf binary and import the required objects to run it inside the directory that the binary is in.

This is from a virtualization perspective the kernel we use is linux based and Im purely looking at a way to improve development of apps on Windows. The only thing I want to do with the files is be able to read them and copy to a location without any changes. But most elf objects link to shared libraries that are symlinks but Windows doesn't seem to know what to do with that file. Any sort of open on that file results in system could not find the name specified. I assume this is because the explorer is attempting to open the symlink but its at a path it doesn't understand like '/lib/64' instead of '\wsl$\Ubuntu\lib\64'.

Describe the solution you'd like
Maybe on the file open in the windows explorer prefix it with the location of the symlink. '/lib/64' turns into opening '\wsl$\Ubuntu\lib\64' I imagine this would be a big task probably.

Describe alternatives you've considered
I could probably resolve this from the perspective of installing another daemon on my subsystem and just do the calls there. I'm mainly querying about this so I can improve UX of our application and the user doesn't have to install two of the same thing.

Is there a use case where we could set the LD_LIBRARY_PATH on our Windows machine to point to one of the sub system shares?

Additional context
Basically want to read the ldd of an elf binary copy the objects into a windows directory. Proceed to do that recursively for everything that binary requires.

@therealkenc therealkenc changed the title Gathering Shared Libraries for an Elf Binary from the WSL Share access Linux symlinks from \\wsl$ Apr 23, 2020
@therealkenc
Copy link
Collaborator

Yeah. Another thing I've observed is the names don't show in powershell:

image

One work-around which I happened to have handy from another post is to use Samba:

image

Is there a use case where we could set the LD_LIBRARY_PATH on our Windows machine to point to one of the sub system shares?

No that's actually not well formed. Windows has never heard of a LD_LIBRARY_PATH.

Basically want to read the ldd of an elf binary copy the objects into a windows directory

You're almost certainly on the wrong side of the fence. Gather whatever it is you are gathering on the WSL side with interop.

image

If what you're gathering is more complex than that, do the more complex thing on the WSL side too.

@ghost
Copy link

ghost commented May 23, 2020

OP's use case may be overkill, but it would definitely be nice to be able to access Linux symlinks from Windows. Right now, even a directory symlink shows up as a regular file.

@loliconer
Copy link

There are a lot of symlinks in my project on WSL2, and they can't be opend in windows 10(2004) file explorer and also any GUI editors. Hopefully this issue can be resolved.

@fuweichin
Copy link

From Windows 10 version 1903, WSL allow Windows apps change Linux files via path prefixed \\wsl$\, see Do not change Linux files using Windows apps and tools and A Deep Dive Into How WSL Allows Windows to Access Linux Files.

One common use case is using a Windows application to edit a Linux configuration file, since symlink config files are quite common in Linux, e.g. \\wsl$\Debian\etc\nginx\sites-enabled\default, this feature is an important step towards better interoperability.

Some expectations for Linux symlink in WSL:

  • can be accessed by Windows' built-in applications (like Notepad), or third-party applications.
  • [bonus] when shown in Windows Explorer, its icon will be decorated with a link icon at bottom-left conor, just like what Windows symlink was decorated.
  • [bonus] when shown file properties in Windows Explorer, target path will be present.

It will take some effort on Windows Explorer and WSL's 9P server.

@geff21st
Copy link

Any news about this problem? Any chance that windows explorer and other apps (IDEs for example) will support WSL symlinks?

@zzzachzzz
Copy link

In WSL 1, it was recommended to keep files shared between Windows & Linux in Windows, and in Linux access them through a mount (/mnt/c/). In WSL 2, it is now recommended to keep those files in the Linux filesystem, for performance reasons. When I used WSL 1 and kept files in Windows, I could use a Windows link for a directory (mklink /D). After transitioning to WSL 2 and keeping my files in the Linux filesystem, there doesn't appear to be any way for me to create a link to a directory that Windows will understand.

@proligde
Copy link

proligde commented Feb 4, 2021

Any news on that? This feature would make it possible to run a dev environment (which usually always has some symlinks somewhere) in WSL2 while running the IDE in Windows. That would really supercharge the power of WSL2

@zulkar
Copy link

zulkar commented Feb 5, 2021

Agree with @proligde
This bug makes quite hard complete IDE integration with WSL2 - If IDE is running under windows, it cannot read files data, if file is a symlink. Which happens on >95% of all environments.

@IlanVivanco
Copy link

IlanVivanco commented Feb 5, 2021

Having this would be ideal for PHP development. I'm always having trouble mapping a local WordPress app to a plugin/theme developed on the WSL2 side.

Creating the Symlink it's possible and works great on the explorer. But that symlink is not accessible afterward via PHP.

C:\Users\ilan\www\wp\wp-content\plugins>mklink /D my-plug \\wsl$\Ubuntu-20.04\home\ilan\code\best-practices
symbolic link created for my-plug <<===>> \\wsl$\Ubuntu-20.04\home\ilan\code\best-practices

image

@uar-agustin-didiego
Copy link

+1

@wiput1999
Copy link

+1 I've faced this problem too

@aeremichev
Copy link

+100500

@mmsheeks
Copy link

+1 this would be extremely helpful.

@xmontero
Copy link

xmontero commented Apr 22, 2021

My use case

WSL2 side:

  • Developing PHP application under /files/repos/my-nice-app and library in /files/repos/my-nice-lib in separate repos.
  • Application uses library.
  • composer in the application is configured so doing composer install links the vendor/my-nice-vendor/my-nice-lib to the library's original dir, instead of copying the files, so real-time changes in the library while being developed are loaded in the application too.

Windows side:

  • Open project "my-nice-application" in PhpStorm and all the auto-completion fails because the IDE cannot read what is under the vendor libraries.

Conclusion

Without auto-completion the developer's experience is broken.

This compares to a prior setup in which instead of sharing via \\wsl$\ it was shared from a linux server via samba and all worked perfectly (the samba server reads the links and exposes them as regular files (linux to windows direction) and symmetrically when the windows edits a file under link, the server touches the original location).

I think the fix for this issue should be located in the source of the \\wsl$ share engine behaving exactly as samba does.

@xmontero
Copy link

Crossreferenced here https://intellij-support.jetbrains.com/hc/en-us/community/posts/360008368679-Project-files-on-WSL2-with-symlink-support

@xmontero
Copy link

It is probably a problem located in the P9 file server. Should we open the bug in a repo specific to the P9 file sharing thing? Or the P9 team is looking at this repo as the main source to guide their development?

I'd be more than happy to contribute (if my knowdlege permits it haha) to code/solve this bug if someone helps me to bootstrap the dev environment and directs me to the place where to look at.

@Yolo-plop
Copy link

Need this pretty please. My use case is quite simple, i work on an Angular project which uses a node_module that we update frequently, so we have a link between the dist output and the node_modules of the project, but it messes with the IDE that can't see the files.

@DamirPecnik
Copy link

DamirPecnik commented May 19, 2021

I am using WSL2 and Lando and everything is working ok in WSL for it except the symlinks. When I want to connect the symlink in WordPress to the theme or plugin folder WordPress doesn't see them.

If I hit this in terminal ls -ls i get the connection shown but it doesn't work.

image

I believe this is an urgent matter, any idea when it will be resolved?

@xmontero
Copy link

@DamirPecnik You see the link "in" the linux side but "not in" the windows side?

@DamirPecnik
Copy link

@DamirPecnik You see the link "in" the Linux side but "not in" the windows side?

Symlinks created in Windows can't be seen in Linux by PHP, for example, the theme in the theme folder in WordPress is not there.

@illgenr
Copy link

illgenr commented Jun 18, 2021

Ran into this issue with a NixOs build of a Haskell project. The output is compiled into a bin folder that is sym linked to the /nix directory which changes hashes every build.

Can't use a windows command to open a file in the sym linked folder. Maybe unrelated, but why aren't sym links converted windows shortcuts in the file explorer?

@Sebanisu
Copy link

https://youtrack.jetbrains.com/issue/CPP-25670 I opened an issue because clion couldn't see past the \wsl$ path to png.h. Though everything compiles there is alot of red underlines in the ide because of this.

@emeGuan
Copy link

emeGuan commented Apr 25, 2023

I use WSL2+Samba by the problem with symlinks.
Developer in vuejs, PHP and Java.
All the code in WSL and access to the code (with samba) from Windows with PhpStorm(vue and php) and Eclipse (java).
The performance is good and for me all ok.

@maicol07
Copy link

I'm currently using PHPStorm on WSL (through snap package) +  GWSL to develop and it's good for daily use (there are some issues sometimes with dialogs closing after they opened).

This issue has been here for a while and as a Jetbrains user working on WSL, I feel like I'm stuck between the silence of Microsoft here and the "we can't do anything unless this is solved in WSL" of Jetbrains.

@toyi actually, that's not really true. JetBrains is currently working on a new "WSL agent" which should be in charge of OS interaction. If this will work, we'll be able to use symlinks on the Windows IDE in a WSL project! I hope we'll be able to see it in the first 2023.2 EAP build.
Source: https://youtrack.jetbrains.com/issue/IDEA-293604/IntelliJ-is-slow-hanging-when-working-with-WSL-filesystem#focus=Comments-27-6939089.0-0

@Yolo-plop
Copy link

Gui apps just work fine in WSL. Just make sure your WSL installation is up to date (wsl --update in a Windows terminal), get Jetbrains toolbox for Linux, execute it from the terminal, install PHPStorm of whatever and call it from the terminal.

I also run Gitkraken directly in Linux GUI, there were problems with some file informations when trying to run it from Windows.

@toyi
Copy link

toyi commented Apr 25, 2023

@toyi actually, that's not really true. JetBrains is currently working on a new "WSL agent" which should be in charge of OS interaction. If this will work, we'll be able to use symlinks on the Windows IDE in a WSL project! I hope we'll be able to see it in the first 2023.2 EAP build.

Indeed, I missed that and this is a pretty good news !

@AndrewBogdanovTSS
Copy link

2023.1 already has Remote Development feature that allows you to connect to WSL and run it in a proper context. The feature is in Beta now and is quite unstable but let's hope it will get better through time

@maicol07
Copy link

2023.1 already has Remote Development feature that allows you to connect to WSL and run it in a proper context. The feature is in Beta now and is quite unstable but let's hope it will get better through time

I know but it currently behaves as a separate IDE and it has some issues with plugins and themes and some features are missing from the local IDE (such as some fix suggestions).

@AndrewBogdanovTSS
Copy link

Yes, that's what I meant by "unstable" 🙂

@realjjaveweb
Copy link

So I still see no milestone, no assignee and mainly - no PR - what is the current state of this?
This is still very much needed for working with it out of the box on Windows.

@oldium
Copy link

oldium commented Jun 20, 2023

@benhillis Are there any plans to implement symbolic links through the wsl$ paths, please? Projects already started skipping creating symbolic links in WSL2 because of missing support when accessing the files from Windows. JetBrains IDEs also suffer from issues with symbolic links when using WSL2.

@haosmos
Copy link

haosmos commented Jun 27, 2023

Hi guys!

is there any news on this issue? many people have been waiting for a solution to this problem for many years.

@Anatolych97
Copy link

Anatolych97 commented Jul 21, 2023

The moment when the company does not care about their users. They can't even officially refuse this functionality.

@mark-langer
Copy link

Hi @craigloewen-msft, I can see you're quite active in this repo. Is there any chance you could find the right person on the Microsoft team to reply to this thread? 🙏

@ryanjshaw
Copy link

ryanjshaw commented Oct 10, 2023

Hello. In case it is of interest to you. How to access the WSL2 file system from Windows with Samba. Samba transforms symlinks into Windows folders, so symlinks don't present any problem for filesystem use from Windows. The article is written in Spanish, it is very easy to follow using the translator integrated into linkedin. Best regards https://www.linkedin.com/pulse/acceso-wsl2-desde-windows-con-samba-manuel-nicol%C3%A1s-ortu%C3%B1o/

This works pretty well as a tactical solution.

I've setup a .ps1 script to deal with the IP address changing:

# Get the IP address from WSL
$ip = wsl hostname -I | Out-String
$ip = $ip.Trim() # Remove any whitespace

# Map the drive. -Persist is necessary to expose the drive outside the PSSession.
New-PSDrive -Name S -PSProvider FileSystem -Root "\\$ip\shared" -Persist

This script works without explicit credentials if your Windows username/password matches your samba username and password.

The other option would be sshfs but that's not natively supported by Windows.

@drunkwolfs
Copy link

Есть новости по этой задаче?

@wursta
Copy link

wursta commented Dec 14, 2023

It seems that Microsoft has given up on fixing this bugfeature...

@haosmos
Copy link

haosmos commented Dec 16, 2023

guys, hi! 😃

It will be great if this problem is solved! The community has been waiting for a solution to this problem for many years.

@popuguytheparrot
Copy link

turborepo with pnpm, yarn workspaces not working on wsl2 ubuntu image

@mohamedelkony
Copy link

+1

1 similar comment
@Giovancruz
Copy link

+1

@Stanzilla
Copy link

@benhillis any chance this can get looked at?

@szpolny
Copy link

szpolny commented Feb 9, 2024

4 years later and still waiting

@Ruvik
Copy link

Ruvik commented Mar 22, 2024

+1

@oldium
Copy link

oldium commented Mar 25, 2024

There is a Subscribe button if you want to follow. Sending +1 to more than 200 people seems rude. Thanks.

@realjjaveweb
Copy link

There is a Subscribe button if you want to follow. Sending +1 to more than 200 people seems rude. Thanks.

It's not about follow, it's about saying "I too support this issue" for an issue that is not solved for 4 years.

It's about bringing attention and keeping the thread alive...

The issue is more and more pressing since symlinks are getting in volume.

@robere2
Copy link

robere2 commented Apr 4, 2024

There is a Subscribe button if you want to follow. Sending +1 to more than 200 people seems rude. Thanks.

It's not about follow, it's about saying "I too support this issue" for an issue that is not solved for 4 years.

It's about bringing attention and keeping the thread alive...

The issue is more and more pressing since symlinks are getting in volume.

I really hate to contribute to the email spam here, but giving a thumbs-up will push the issue closer to the top of the most popular feature request issues: https://github.com/microsoft/WSL/issues?q=is%3Aissue+is%3Aopen+label%3Afeature+sort%3Areactions-%2B1-desc

If you look there, you'll see this feature is currently the 8th-most requested feature for WSL. Sorting feature requests by most recently active is not exactly a good metric (at least in my opinion), partially for the reason mentioned above, but also because discussion != support. If you want to comment every couple months just to make sure it doesn't get regarded as fixed through some other means, fine... There is no need to consistently keep this issue on the front page of most-recently-updated feature requests. This is how issues get locked.

I have no authority in this regard, but I question whether this may violate the repository's Code of Conduct "disruptive behavior".

@sirredbeard
Copy link
Contributor

This issue was brought to my attention on Twitter. I have no inside information on this, but I do have a theory as to why this issue persists/feature request is still outstanding.

Windows to WSL file sharing via the UNC path, e.g. \\WSL$\fedoraremix, is handled by 9p file server/client, part of the broader 9p network protocol. The WSL2 init process loads a 9p file server in the WSL distro and can be connected to via a driver in Windows, specifically C:\Windows\System32\drivers\p9rdr.sys.

This is not unlike the virtio implementation of 9p for QEMU and KVM.

9p is a very simple, fast, lightweight protocol for file sharing, which is descended from the Plan 9 operating system. It makes sense from a speed perspective to use over NFS or Samba and was much simpler to implement. 9p also avoids the GPL licensing issues that NFS and Samba would introduce.

The issue here, I suspect, is that the Plan 9 OS, and thus 9p, never adopted symbolic links from its predecessor, UNIX, which Linux was heavily influenced by, via MINIX.

Rob Pike, who worked on UNIX at Bell Labs, alongside Ken Thompson, with help from Dennis Ritchie, later worked on Plan 9 as a successor to UNIX which shed many of its complexities. Pike specifically rejected symbolic linking in Plan 9. You also know Pike as the inventor of Go.

A search of GitHub issues shows several other projects that implement 9p also lack symbolic link support, such as minikube.

WSL implements the 9p2000.l dialect of 9p, which is a lightweight subset of 9p2000 which specializes in data types relevant to Linux system calls, maps directly to the Linux file system, and provides speed enhancements for Windows to WSL file operations.

The alternative would be to implement the 9p2000.u dialect of 9p which does implement symbolic links, but would not include the Linux-specific enhancements and be more challenging to implement.

This appears to be a tradeoff made between simplicity/speed and full support for things like symbolic links. This is just my theory, but I wanted to provide some potential context to the discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests