Vscode-remote-release: Instead of home directory, VS Code terminal defaults to /mnt/c/Users/username/.vscode/extensions/ms-vscode-remote.remote-wsl-0.44.4$

Created on 9 Jul 2020  路  12Comments  路  Source: microsoft/vscode-remote-release

Description

First, I open the Ubuntu terminal, navigate to /home/kp/programming, and type code .

The folder is loaded correctly in VS Code's sidebar, but the terminal defaults to /mnt/c/Users/krist/.vscode/extensions/ms-vscode-remote.remote-wsl-0.44.4$

Even if I right-click a file, and choose Open in Terminal, I'm still at mnt/c/....

This happens even if I disable all extensions (except Remote - WSL of course) and comment out settings.json.

I can navigate by typing into the terminal, but if I try to right-click the file in the sidebar, and Open in Terminal, VS Code's terminal goes back to /mnt/c/...

VS Code dev tools doesn't seem to show anything related:

/C:/Users/krist/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:4072 [xabikos.JavaScriptSnippets]: Unknown language incontributes.JavaScriptSnippets.language. Provided value: vue _logMessageInConsole @ /C:/Users/krist/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:4072 /C:/Users/krist/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:265 [Extension Host] Quokka.js Live Share integration disabled, VSLS not found.

Info

Version: 1.46.1 (user setup)
Commit: cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
Date: 2020-06-17T21:13:20.174Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.19041

WSL 2
Ubuntu 20.04

needs-more-info wsl

Most helpful comment

After digging in more, I found out exactly what caused this issue. WSL2 does not play nice with Snap Packages. There is a site that steps you through how to get Systemd and Snap Packages working on WSL2. It is the quick installation script that causes the issue. I didn't dig into the details why, I just rolled back to a previous ubuntu backup before the install and this issue went away. Just sharing this here in case anyone else runs into the problem.

All 12 comments

I just discovered that Bash didn't recognize some commands which do work in the plain Ubuntu terminal.

Choosing Dash as my default shell in VS Code solved the problem. However, I'd rather recommend installing zsh for a nicer experience.

Can you clarify: Anything that needs to be fixed on the VSCode side? Or was it a bug in one of your scripts?

These were specifically two globally installed npm packages: live-server and nodemon. They work in zsh, but no longer work in bash. This only applies in the VS Code terminal - the standalone Ubuntu terminal still works fine.

With zsh, the VS Code terminal defaults to my WSL home directory.

With Bash, the VS Code defaults to /mnt/c/Users/krist/.vscode/extensions/ms-vscode-remote.remote-wsl-0.44.4$

Can your share your settings.json file and run echo $SHELL in the terminal?

echo $SHELL logs out /bin/bash

Here's my VS Code 1.47 settings.json:

{
    "editor.acceptSuggestionOnCommitCharacter": false,
    "editor.insertSpaces": false,
    "editor.tabSize": 4,
    "explorer.confirmDragAndDrop": false,
    "editor.quickSuggestions": {
        "other": true,
        "comments": false,
        "strings": false
    },
    "workbench.sideBar.location": "right",
    "editor.minimap.showSlider": "always",
    "telemetry.enableTelemetry": false,
    "telemetry.enableCrashReporter": false,
    "update.showReleaseNotes": false,
    "extensions.autoCheckUpdates": false,
    "extensions.autoUpdate": false,
    "workbench.colorCustomizations": {
        "editorLineNumber.foreground": "#999",
        "titleBar.inactiveBackground": "#303546"
    },
    "window.zoomLevel": 1,
    "search.exclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/env": true,
        "**/venv": true
    },
    "files.watcherExclude": {
        "**/.git/objects/**": true,
        "**/.git/subtree-cache/**": true,
        "**/node_modules/**": true,
        "**/env/**": true,
        "**/venv/**": true,
        "env-*": true
    },
    "files.exclude": {
        "**/.git": true,
        "**/.DS_Store": true,
        "**/.vscode": true,
        "**/__pycache__": true,
        "**/.pytest_cache": true,
        "**/node_modules": true,
        "venv": true,
        "*.sublime-*": true,
        "env*": true
    },
    "editor.renderWhitespace": "none",
    "workbench.startupEditor": "newUntitledFile",
    "git.enableSmartCommit": true,
    "extensions.showRecommendationsOnlyOnDemand": true,
    "extensions.ignoreRecommendations": true,
    "typescript.validate.enable": false,
    "editor.lineHeight": 24,
    "editor.matchBrackets": "never",
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "window.menuBarVisibility": "default",
    "editor.formatOnPaste": true,
    "git.confirmSync": false,
    "bracket-pair-colorizer-2.colors": [
        "hsla(0, 20%, 50%)",
        "hsla(180, 20%, 50%)",
        "hsla(45, 20%, 50%)",
        "hsla(235, 20%, 50%)",
        "hsla(300, 20%, 50%)",
    ],
    "bracket-pair-colorizer-2.activeScopeCSS": [
        "borderStyle : solid",
        "borderWidth : 1px",
        "borderColor : {color}",
        "opacity: 0.5"
    ],
    "[elixir]": {
        "editor.defaultFormatter": "JakeBecker.elixir-ls"
    },
    "terminal.integrated.shell.linux": "/bin/zsh",
    "terminal.integrated.automationShell.linux": "",
    "sync.gist": "19f0f0579970fe661a3cf0dcfa666d9d",
    "editor.copyWithSyntaxHighlighting": false,
    "editor.fontFamily": "Fira Code Retina",
    "editor.fontSize": 12,
    "python.languageServer": "Microsoft",
    "workbench.colorTheme": "Material Theme Palenight High Contrast",
    "workbench.iconTheme": "eq-material-theme-icons-palenight"
}

I also tried Insiders 1.48.0, which has never been installed on this machine. It too fails to start at my Ubuntu home directory, but it doesn't start in the same place as 1.47 - it starts at /mnt/c/Users/krist

{
    "terminal.integrated.shell.windows": "C:\\Windows\\System32\\wsl.exe"
}

For me personally, zsh is an acceptable fix, but it would be interesting to figure out why this is happening.

Can you run a trace log when launching the terminal? This will tell us what cwd the process was told to spawn under https://github.com/microsoft/vscode/wiki/Terminal-Issues#enabling-trace-logging

I didn't see a resolution here so I'm adding my trace log as I'm experiencing the exact same issue. Only including the terminal detail. Let me know if you need more. Side note: if I change terminal.integrated.cwd it throws an error as if it's appending to CWD below. It seems as if the other path, called out by the OP, is overwriting it at some point.

[2020-09-22 13:49:45.532] [exthost] [trace] IPty#spawn /bin/bash [] {"name":"xterm-256color","cwd":"/home/josh/Sites/sh-atd","env":{"SUDO_GID":"0","MAIL":"/var/mail/josh","USER":"josh","PRE_NAMESPACE_PATH":"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/ProgramData/DockerDesktop/version-bin:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Users/jooos/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/jooos/AppData/Local/Programs/Microsoft VS Code/bin","SHLVL":"0","HOME":"/home/josh","WSL_DISTRO_NAME":"Ubuntu","SUDO_UID":"0","PRE_NAMESPACE_PWD":"/mnt/c/Users/jooos/.vscode/extensions/ms-vscode-remote.remote-wsl-0.44.5","LOGNAME":"josh","WSL_INTEROP":"/run/WSL/7499_interop","_":"/home/josh/.vscode-server/bin/58bb7b2331731bf72587010e943852e13e6fd3cf/node","TERM":"xterm-256color","PATH":"/home/josh/.vscode-server/bin/58bb7b2331731bf72587010e943852e13e6fd3cf/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/ProgramData/DockerDesktop/version-bin:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Users/jooos/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/jooos/AppData/Local/Programs/Microsoft VS Code/bin:/snap/bin","LANG":"C.UTF-8","SUDO_COMMAND":"/bin/bash -c set -a; [ -f \"$HOME/.systemd-env\" ] && source \"$HOME/.systemd-env\"; set +a; exec bash -c sh\\ -c\\ \\'\\\"\\$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh\\\"\\ 58bb7b2331731bf72587010e943852e13e6fd3cf\\ stable\\ .vscode-server\\ 0\\ \\ \\'","SHELL":"/bin/bash","SUDO_USER":"root","PWD":"/mnt/c/Users/jooos/.vscode/extensions/ms-vscode-remote.remote-wsl-0.44.5","HOSTTYPE":"x86_64","WSLENV":"VSCODE_WSL_EXT_LOCATION/up:BASH_ENV/u","LS_COLORS":"rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:","LESSCLOSE":"/usr/bin/lesspipe %s %s","LESSOPEN":"| /usr/bin/lesspipe %s","XDG_DATA_DIRS":"/usr/local/share:/usr/share:/var/lib/snapd/desktop","OLDPWD":"/","AMD_ENTRYPOINT":"vs/server/remoteExtensionHostProcess","PIPE_LOGGING":"true","VERBOSE_LOGGING":"true","VSCODE_IPC_HOOK_CLI":"/tmp/vscode-ipc-cb2d943b-04fc-4cb6-a62e-866730d0f493.sock","TERM_PROGRAM":"vscode","TERM_PROGRAM_VERSION":"1.49.1","COLORTERM":"truecolor","VSCODE_GIT_IPC_HANDLE":"/tmp/vscode-git-6ac98424ae.sock","GIT_ASKPASS":"/home/josh/.vscode-server/bin/58bb7b2331731bf72587010e943852e13e6fd3cf/extensions/git/dist/askpass.sh","VSCODE_GIT_ASKPASS_NODE":"/home/josh/.vscode-server/bin/58bb7b2331731bf72587010e943852e13e6fd3cf/node","VSCODE_GIT_ASKPASS_MAIN":"/home/josh/.vscode-server/bin/58bb7b2331731bf72587010e943852e13e6fd3cf/extensions/git/dist/askpass-main.js"},"cols":0,"rows":0,"useConpty":false,"conptyInheritCursor":false}

Reinstalling a new Ubuntu wsl2 instance and copying over my source files fixed this issue for me. Not sure if there was an update in Ubuntu that caused the issue or some other config that I touched, but I'm glad to have the working directory working again.

Glad to hear the problem was resolved @jooosh!

@kristianpedersen Are you still experiencing this issue?

After digging in more, I found out exactly what caused this issue. WSL2 does not play nice with Snap Packages. There is a site that steps you through how to get Systemd and Snap Packages working on WSL2. It is the quick installation script that causes the issue. I didn't dig into the details why, I just rolled back to a previous ubuntu backup before the install and this issue went away. Just sharing this here in case anyone else runs into the problem.

Sorry, I forgot about this issue. I re-installed WSL+Ubuntu, and everything worked.

Snap might have been the issue in my case as well.

Thanks for the info!

Was this page helpful?
0 / 5 - 0 ratings