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

doesn't work for a drive mounted to root / #42

Closed hibernick closed 5 years ago

hibernick commented 5 years ago
 $ mount 
 ...
 C: on /c type drvfs (rw,noatime,uid=1000,gid=1000,umask=22,fmask=111,metadata)
 D: on /d type drvfs (rw,noatime,uid=1000,gid=1000,umask=22,fmask=111,metadata)
$ cat  /etc/wsl.conf
[automount]
root = /
options = "metadata,uid=1000,gid=1000,umask=22,fmask=111"

vscode output:

Open repository: \d\work\projects\proj
> git status -z -u
> git rev-parse --show-toplevel
fatal: Not a git repository (or any parent up to mount point /d)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
andy-5 commented 5 years ago

Yes, this is a known issue, as wslgit currently does not honor settings in wsl.conf. There is some discussion in #12 on how to fix this, but no implementation for now.

One possible temporary workaround, until this is implemented, is to use the old way of configuring your setup using bind mounts. This kind of works, but leads to other problems in some situations, as discussed in #34 .

I'll leave this issue open for now as a concise example for the wsl.conf setup and resulting mount points.

nickjj commented 5 years ago

I'd really like to see this work with / as well. Going back to /mnt can't happen for me. Also I tried symlinking /mnt/c to /c and that also didn't work.

I never compiled a Rust app before, but if you change the hard coded /mnt to /, would it work?

weissglut-dev commented 5 years ago

I never compiled a Rust app before, but if you change the hard coded /mnt to /, would it work?

I just tried that and it works

GuillaumedesPommareSAP commented 5 years ago

It would be nice if you could share your compiled wslgit.exe somewhere, because putting in place the build environment when you don't have all the required tools is really time consuming.

Maybe providing two variants, one with / and the other with /mnt/, if it is not complex to do, would help people forced, as I am, to switch their mounting point to / ?

GuillaumedesPommareSAP commented 5 years ago

If anyone needs to make it working, the 'easiest' way is to go through the installation of VS Tools 2018 + W10 SDK. I tried to use cargo+rust under WSL to generate a .exe but it's really tricky and complex to set up. Then you will need to modify two lines: l27 format!("/{}", drive) and l76 Regex::new(r"(?m-u)/(?P<drive>[A-Za-z])(?P<path>/\S*)")

And a build, and here you go, it works with a mount on root /c/here/i/am I can share a build, if needed, but sharing .exe outside this site could be risky for the receiver.

andy-5 commented 5 years ago

Great! Nice to hear that it works in principle. Note, however, that this could fail in some edge cases, e.g. if the output of some translated git command contains slashes that are not part of a path (but only few git commands are actually translated).

I think many will find this useful, so I've added a new build with these changes (which are now in the mount-at-root branch) to the latest release - just grab the wslgit-mount-at-root.exe binary there.

I'm also closing this issue, as these changes seem to solve this specific use case.