1

I have one specific directory (they key is the directory name, see below) on my filesystem where starting the wsl shell will always start me out in the home directory instead. Like so:

PS C:\Source\Code\contentmatch.stream> wsl
jjk@pc-name:~$

Trying to do the same through the file explorer dialogue option (open Linux shell here) has the same effect.

Behind the hood, the command that actually does this has the same effect as well

PS C:\Source\Code\contentmatch.stream> wsl --cd "C:\Source\Code\contentmatch.stream"
jjk@pc-name:~$

This does not happen in any other directory. Renaming this directory to anything else mitigates the issue. Creating another directory with same name will again trigger the same behaviour. I can access that directory from the WSL level without any issues. I've string searched the registry for any references to said string, but nothing there.

After reading this: WSL open linux shell here doesn't open in the current directory Have tried also this command, but the result was the same:

PS C:\Source\Code\contentmatch.stream> wsl --cd "C:\Source\Code\contentmatch.stream" -e bash --noprofile --norc
bash-5.0$ ls
LICENSE  datadump.jsons  efs-utils  error  out  output  packages-microsoft-prod.deb
bash-5.0$ exit
exit
PS C:\Source\Code\contentmatch.stream>

It appears to me as if there's some mapping file which redirects or otherwise disables this particular path from starting wsl but having searched far and wide online, I can't identify what that is.

Where do I look for the cause of this behaviour?

14
  • Thanks for reposting over here. I was going to suggest the bash --noprofile --norc, but you found that already. What distribution are you using? Here's my result under Ubuntu 20.04: wsl --cd "C:\Source\Code\contentmatch.stream" -e bash --noprofile --norc -c pwd correctly results in /mnt/c/Source/Code/contentmatch.stream. Trying to noodle out a reason why yours is different. Feb 12, 2021 at 21:59
  • I'm on ubuntu 20.04 as well.
    – JKJ
    Feb 12, 2021 at 22:16
  • Also should mention that I've tried under both PowerShell and PowerShell Core (latest version, 7.1.2, released yesterday). Both work correctly here. I'm as stumped as you are on why that directory name is "magic" for you. Feb 12, 2021 at 22:20
  • Two more suggestions -- Try with wsl --cd "C:\Source\Code\contentmatch.stream" -u root -e bash --noprofile --norc -c pwd (running as the root user). If that still gives the same results, try with a different distro/instance entirely, maybe 18.04 or Alpine. Just something to start a new instance that doesn't have any remnants from your current one. Then modify the same command again with wsl -d <distroname> --cd "C:\Source\Code\contentmatch.stream" -e bash --noprofile --norc -c pwd Feb 12, 2021 at 22:23
  • Although I should mention that Alpine is a minimal install that doesn't install bash by default, so it would be wsl -d Alpine --cd "C:\Source\Code\contentmatch.stream" -e sh -c pwd (insert the correct distro name for Alpine, whatever that is). Feb 12, 2021 at 22:31

1 Answer 1

1

In this case I have identified that disabling docker made it work. But after restarting it the problem came back.

Upon further search for possible references, the problem went away after wiping clean this directory: mnt/wsl/docker-desktop-bind-mounts/
Never got to finding the root cause of why the references in that directory were causing this issue.

1
  • 1
    Greatest consultation credits got to @NotTheDr01ds
    – JKJ
    Feb 16, 2021 at 20:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .