microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
16.95k stars 799 forks source link

access Linux symlinks from \\wsl$ #5118

Open trentis opened 4 years ago

trentis commented 4 years ago

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 commented 4 years ago

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.

0xallie commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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:

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

geff21st commented 3 years ago

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

zzzachzzz commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

+1

wiput1999 commented 3 years ago

+1 I've faced this problem too

aeremichev commented 3 years ago

+100500

mmsheeks commented 3 years ago

+1 this would be extremely helpful.

xmontero commented 3 years ago

My use case

WSL2 side:

Windows side:

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 commented 3 years ago

Same asked here time ago: https://stackoverflow.com/questions/64489501/wsl2-linux-relative-symlinks-broken-when-accessed-from-windows-only-for-the

xmontero commented 3 years ago

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

xmontero commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

DamirPecnik commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

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.

lemonsaurus commented 2 years ago

This problem is a complete showstopper for me. I really like WSL2, but without fully functioning symlinks I can't see how I can use it for dev. I really hope this issue is on your radar.

Yolo-plop commented 2 years ago

Just thought about this but a temporary solution could be to use an auto rsync instead of a symlink.

IlanVivanco commented 2 years ago

Just thought about this but a temporary solution could be to use an auto rsync instead of a symlink.

Could you elaborate on that?

Yolo-plop commented 2 years ago

An alternative to symbolic link is to just keep the two folders synchronized.

https://stackoverflow.com/questions/12460279/how-to-keep-two-folders-automatically-synchronized

In my case it would work find because i simply need to copy the build of a library into the application using this library, which i've been doing manually, which is stupid and time consuming.

forresthopkinsa commented 2 years ago

Duplicating a directory and keeping it synchronized is, unfortunately, not a real solution to the problem

xmontero commented 2 years ago

Devel team: Any news on this? I would be happy to contribute but I need guidance on what to investigate/code.

overherz commented 2 years ago

how long?

drunkwolfs commented 2 years ago

please fix it

xmontero commented 2 years ago

xref: https://superuser.com/q/1695779/324451

ericjeker commented 2 years ago

Any news on this bug? This is breaking many tools.

ohroy commented 2 years ago

any news ?

misaon commented 2 years ago

So come on Microsoft, make developers happy and WSL even more usable! it's been taking an unnecessarily long time… 🚀

GrzegorzKlimek commented 2 years ago

bump

ltomov commented 2 years ago

An ugly workaround may be to use the unison app to continuously sync between the two folders:

unison \
  -repeat watch \
  -copyonconflict \
  -prefer newer \
  "/folder1/" \
  "/folder2/"

You can run several instances and keep multiple symlinks this way.

But a much more elegant way is if you use VSCode, it has an option "Open WSL Window" - this window is able to follow the symlinks.

lichenbo commented 2 years ago

+1 on the feature

debel27 commented 2 years ago

@benhillis @OneBlue I'm sorry to bring you into this, but I think many of us would love to hear from a maintainer at this point.

Is there any status you can give us about this symlink issue ?

Neiso commented 2 years ago

😢

delucca commented 2 years ago

Almost 2 years now. No news about this?

Symlinks are a basic Linux feature.

GimpMaster commented 2 years ago

Looks like this has been on the issue list for a couple years. Following...however not hopefull. Discovered this issue when trying to use pnpm and Webstorm IDE not being able to follow symlinks.

nachocodoner commented 2 years ago

Same problem here when using yarn workspaces which uses symbolic links. When using it on software like Webstorm that connects to wsl directory, those files stop to work as symblink are not properly handled.

When would we get a fix on this?

misaon commented 2 years ago

Buy MacBook, this issue si ignored by authors 😆

delucca commented 2 years ago

Looks like this has been on the issue list for a couple years. Following...however not hopefull. Discovered this issue when trying to use pnpm and Webstorm IDE not being able to follow symlinks.

Same thing here. And it seems that they're simply ignoring this.

grmlin commented 2 years ago

Same thing here. And it seems that they're simply ignoring this.

the last time they couldn't fix a major problem (IO performance) they created a new and completely different version of WSL lol. I don't have much hope here, as symlinks in Linux simply can't be replicated in Windows afaik.

If anything we need better tools that work with WSL 2 natively. Like VS Code, which is wonderful. But that's about it, I don't know a single other IDE, Git Client or whatever that works as good as this :/

culyun commented 2 years ago

Comeon Redmond!!

loliconer commented 2 years ago

Looks like this has been on the issue list for a couple years. Following...however not hopefull. Discovered this issue when trying to use pnpm and Webstorm IDE not being able to follow symlinks.

Same issue, and what I can do is setting node-linker=hoisted in .npmrc.

Kekananen commented 2 years ago

I'm running into a need for this as well. Part of the file system I work with is stored in a windows env but the dev env is Linux. I've scoured GitHub for someone how made a script for this already but alas non of the repos actually do this. Maybe for some this repo will help, but I am not an admin on the windows side so I can't install Rust there.

IlanVivanco commented 2 years ago

Has anyone found a temporary solution to this? Should I "manually" sync those folders?