Search code examples
visual-studio-codeterminalworking-directoryterminal-emulator

Visual Studio Code WSL Remote - WSL Terminal Ignoring Cwd


I have read several other forums and posts about setting the default directory when opening a new integrated terminal session to no avail.

When I first start using VSC it seems to open the workspace directory for the first couple days. But it must have synched my settings from a previous install and brought back something that I could never figure out on my previous windows install. For some reason when it opens a terminal it opens to the AppData folder location for Microsoft VS Code as shown below:

<user>@<hostname>:/mnt/c/Users/<user>/AppData/Local/Programs/Microsoft VS Code$

If for instance I go into File > Preferences > Settings and try adding $HOME or ${HOME} I get:

The terminal process failed to launch: STarting directory (cwd) 
"/home/<user>/${HOME}" does not exist.

or

The terminal process failed to launch: Starting directory (cwd) 
"/home/<user>/$HOME" does not exist.

After doing this if I delete the information in Cwd then I receive the error that:

Setting has an invalid type, expect "string". Fix in JSON.

I can fix this by changing the setting to:

"terminal.integrated.cwd": "."

My user profile is basically default:

{
    "workbench.editorAssociations": [
        {
            "viewType": "jupyter.notebook.ipynb",
            "filenamePattern": "*.ipynb"
        }
    ],
    "git.autofetch": true,
    "workbench.colorTheme": "One Dark Pro",
    "python.languageServer": "Pylance",
    "terminal.integrated.scrollback": 10000,
    "terminal.integrated.tabs.enabled": true,
    "terminal.integrated.tabs.location": "left",
    "terminal.integrated.bellDuration": 10000,
    "terminal.integrated.cwd": "."
}

There are only a few settings I changed like tab location and scrollback value.

Any thoughts?


Solution

  • Re-install and newer versions of WSL seemed to be the only fix for this.