i’m currently having a really annoying problem since i ran windows repair on my PC. My wsl remote vscode for some reason that i couldn’t find out in the net, isn’t able to open the current folder in the terminal. Instead, it opens vscode appdata windows folder(/mnt/c/Users/Jonathan/AppData/Local/Programs/Microsoft VS Code), like in the images linked below:
open in integrated terminal result
My remote settings.json file:
{
"go.autocompleteUnimportedPackages": true,
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"icon": "terminal-bash",
"cwd": "/home/jonathanr/Documents/workspace"
},
"zsh": {
"path": "zsh"
},
"fish": {
"path": "fish"
},
"tmux": {
"path": "tmux",
"icon": "terminal-tmux"
},
"pwsh": {
"path": "pwsh",
"icon": "terminal-powershell"
}
}
}
So, turns out i found the solution. To anyone who’s struggling with this problem, the problem was (in my case at least) in one of the env variables that vscode was running wsl with. It is called PRE_NAMESPACE_PWD. If you run WSL with debug enabled (to do this just go to the wsl remote extension settings and turn on the “Remote WSL:Debug” option.) you’ll notice the “env” options in wsl command with all env variables listed there, and if you keep scrolling you’ll notice two variables: PRE_NAMESPACE_PWD and PWD. In this problem, the PRE_NAMESPACE_PWD was pointing to the windows vscode folder instead of the current workspace folder in wsl and the PWD variable was using this folder. To summarize i just exported this PRE_NAMESPACE_PWD variable with the value “${cwd}” which is a command that gets the current workspace folder in my vscode. To do this, simply add this line to your remote Settings.json file:
And that’s it, now everytime you click on “Open with integrated terminal” your terminal is going to open in the right workspace directory.