andy-5 / wslgit

Use Git installed in Bash on Windows/Windows Subsystem for Linux (WSL) from Windows and Visual Studio Code (VSCode)
MIT License
1.18k stars 59 forks source link

Cannot handle path when working from WSL path in Windows #71

Open alecxvs opened 5 years ago

alecxvs commented 5 years ago

The insider build for 1903 has a new functionality that allows browsing files on WSL from explorer. The paths look like \\wsl$\Ubuntu\home\alecxvs\Git\myproject.

Running wslgit from this path gives this error: thread 'main' panicked at 'Cannot handle path "\\\\wsl$\\Ubuntu\\home\\alecxvs\\Git\\myproject"', src\libcore\option.rs:1008:5

andy-5 commented 5 years ago

Yes, it would be nice to support these new paths. Right now, wslgit assumes that Windows paths start with a drive letter (to translate them into a proper unix path).

Adding support for these paths should be possible, e.g. by detecting and removing the prefix.

roonie007 commented 5 years ago

+1

chadrien commented 4 years ago

Adding support for these paths should be possible, e.g. by detecting and removing the prefix.

@andy-5 why don't you use wslpath for things like that? E.g. wsl.exe wslpath -u "\\\\wsl$\\Ubuntu\\home\\alecxvs\\Git\\myproject" would return /home/alecxvs/Git/myproject. Would it make your life easier? :)

andy-5 commented 4 years ago

Thanks for the suggestion (and good to know that it supports these paths). There is already some discussion on wslpath in #12. Unfortunately, it does not solve all problems. The main reasons it is not used are:

rennex commented 4 years ago

It should be super simple to convert WSL2 UNC paths: just add/remove the \\wsl$\Distroname and flip the backslashes. No need to resolve mount paths in that case. However, I'm not sure if there's some special consideration needed for running executables when the current directory is a UNC path. At least .bat scripts have problems with those.

Ideally, this would detect the UNC paths and also work with DrvFs or 9p mounts, so it'd work whether the git repo resides on the Windows side or the Linux side.

andy-5 commented 4 years ago

I just released v0.9.0, which uses wslpath to translate paths (and should handle UNC paths). Does the new version resolve this issue?

Stanzilla commented 4 years ago

Not quite, I have a repo at

\\wsl$\Ubuntu\home\stan\projects\personal\WeakAuras2

and when I go to it via CMD (which is T:\home\stan\projects\personal\WeakAuras2) and type git status it does not detect it as a git repo. When I then type git init, it inits in my WSL user folder,

PS T:\home\stan\projects\personal\WeakAuras2> git init
Initialized empty Git repository in \wsl$\Ubuntu\home\stan\.git
Stanzilla commented 4 years ago

@carlolars any idea for this maybe?

carlolars commented 4 years ago

@carlolars any idea for this maybe?

To access mapped network drives they must be manually mounted inside WSL. wslpath cannot figure out that T: in your case is actually is \\wsl$\Ubuntu since it only gets the windows path (T:\home\stan...). So you have to mount the network drive inside WSL and then wslpath will know how to translate a path that begins with T: to the mounted path.

But unfortunately it seems to not be possible to, in WSL, mount a network drive that points to the WSL filesystem. I even tried to do a bind mount of the root filesystem to my /mnt/t but it didn't work.

I see that you actually use Power Shell and not cmd.exe. In PS you can actually do cd \\wsl$\Ubuntu\home\stan\projects\personal\WeakAuras2 😄

Stanzilla commented 4 years ago

but T IS the WSL mount, how would I mount it inside of WSL?

carlolars commented 4 years ago

but T IS the WSL mount, how would I mount it inside of WSL?

You can't.

Stanzilla commented 4 years ago

Yeah well for this cmd/ps example it does not really matter but I was mainly testing this way because it did not work in Fork either.