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

Can't detect current directory #141

Open VarunAgw opened 5 months ago

VarunAgw commented 5 months ago
  1. I installed it
  2. Ran cd /D d:\www\wm
  3. Ran git status

I got


fatal: not a git repository (or any parent up to mount point /mnt)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
andy-5 commented 5 months ago

Is your drive D: mounted in WSL? Because network drives, removable devices, etc. are not automatically available in WSL.

Does wsl /bin/bash -c 'ls -la /mnt/d/www/wm' work inside Windows CMD/PowerShell? And is there a .git directory in the output?

What is the output of wslpath -au 'D:\www\wm' from within WSL?

If D: is a local hard drive and any of these fails, it would be interesting to know whether you use WSL1 or WSL2 and which Linux distribution is used.

VarunAgw commented 5 months ago

Hi @andy-5

Thanks for the reply

Does wsl /bin/bash -c 'ls -la /mnt/d/www/wm' work inside Windows CMD/PowerShell? And is there a .git directory in the output?

Yes and yes

$ wslpath -au 'D:\www\wm' wslpath: D:\www\wm

It's WSL 1 and Ubuntu 22

I should add it's not a local drive but a subst partition. wslgit works fine on C: Drive though

image

$ ls /d -alh lrwxrwxrwx 1 root root 7 Jan 11 18:14 /d -> /mnt/d/

$ ls /mnt/d -alh lrwxrwxrwx 1 root root 12 Dec 28 2021 /mnt/d -> /mnt/c/Work/

andy-5 commented 5 months ago

Your output

$ wslpath -au 'D:\www\wm' wslpath: D:\www\wm

indicates that wslpath does not work. A valid output would be something like /mnt/d/www/wm.

So it seems this is an issue with wslpath, which cannot correctly handle the subst partition.