VS Code server failed to start when changing directory in bash_profile
- VSCode Version: 1.34 Insider
- Local OS Version: Windows 10 1809
- Remote OS Version: N/A (locally using Ubuntu 18.04 for WSL)
- Remote Extension/Connection Type: WSL
Steps to Reproduce:
- Open a WSL window using "Remote-WSL: New Window"
- "Installing VS Code Server in WSL: Installing WSL components" fails with this error:
VS Code Server for WSL closed unexpectedly. Check WSL terminal for more details
And here are those details:
[2019-05-02 20:19:51.286] Starting VS Code Server inside WSL.
[2019-05-02 20:19:51.602] Launching C:\WINDOWS\System32\wsl.exe bash -i -c "./scripts/wslServer.sh 473af338e1bd9ad4d9853933da1cd9d5d9e07dc9 insider .vscode-remote " in c:\Users\User\.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.31.0
[2019-05-02 20:19:52.625] bash: ./scripts/wslServer.sh: No such file or directory
[2019-05-02 20:19:52.625] VS Code Server for WSL closed unexpectedly.
Does this issue occur when you try this locally?: Yes Does this issue occur when you try this locally and all extensions are disabled?: Yes
Looks like the WSL extensionsdidn't get correctly installed. Can you check the contents of c:\Users\User.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.31.0 ?
I got the same problem.
- VSCode Version: 1.34 Insider
- Local OS Version: Windows 10 Pro, build 17134
- Remote OS Version: N/A (locally using Ubuntu 18.04 for WSL)
- Remote Extension/Connection Type: WSL
- Ext "Remote Development" version: 0.12.0
Contents of directory "ms-vscode-remote.remote-wsl-0.32.0":
CHANGELOG.md
dist/
LICENSE.txt
package.json
package.nls.json
README.md
resources/
scripts/
tests/
tsfmt.json
tslint.json
Contents of the script dir:
wslCode-dev.sh
wslCode.sh
wslDownload.sh
wslServer.sh
can you run the following in a WSL shell? (please replace YourUserName with your windows user name)
bash -x /mnt/c/Users/YourUserName/.vscode-insiders/extensions/ms-vscode-remote.remote-wsl-0.32.0/
scripts/wslServer.sh 473af338e1bd9ad4d9853933da1cd9d5d9e07dc9 insider .vscode-remote
``
@aeschli That seems to work just fine from the wsl side, I end up with Extension host agent listening on 54774
So maybe the problem is the relative path that we use to start the scipt.
When you open a windows command, and cd to c:\Users\YourUserName\.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.32.0 and run wsl.exe, will it open on the corresponding folder?
@aeschli Yup, wsl will open on that folder.
What about C:\WINDOWS\System32\wsl.exe bash -i -c "./scripts/wslServer.sh 473af338e1bd9ad4d9853933da1cd9d5d9e07dc9 insider .vscode-remote " in that folder?
@aeschli That works as well
I have a very similar problem as @sammito1 and @jonaspetersorensen: same messages on startup, no problem running
bash -x /mnt/c/Users/username/.vscode-insiders/extensions/ms-vscode-remote.remote-wsl-0.32.0/scripts/wslServer.sh 473af338e1bd9ad4d9853933da1cd9d5d9e07dc9 insider .vscode-remote
but differently from @jonaspetersorensen, in cmd.exe if i go to the folder of the extension and run wsl.exe from there, I find myself in my home and not in that folder anymore:
C:\Users\username\.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.32.0>cd
C:\Users\username\.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.32.0
C:\Users\username\.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.32.0>wsl
username@laptop:~$ pwd
/home/username
username@laptop:~$
that's maybe the problem for me
@aeschli I have the same problem. In my .bash_profile, I added "cd" so that whenever I run wsl.exe, it will go to ~ instead of "system32". When run code . inside wsl, the error will occur. I try to remove "cd" line and the vscode server wsl started just fine. Hope it help
update: only happen if I set default shell to fish shell via chsh. with default bash/zsh vscode server is okay
I also have a “cd” in my .bash_profile that changes the directory upon starting bash. This is probably where the problem stems from upon starting the vscode server..
I also have a cd in my .bashrc. Removing it solved the problem
Same for me, but interestingly it was in my ~/.config/fish/config.fish - even though vscode's terminal didn't open into fish, it opened into bash (echo $0 results in /bin/bash)
Oh, well spotted regarding the cd :)
I have one in the .bashrc, and when I remove that everything works as expected.
Removing my cd /mnt in .bashrc fixes the issue.
Can you try this version?
- Save the extension as
remote-wsl-0.32.1.vsix(GitHub limitation on files to attach) - in the extensions viewlet, use
Install from VSIX... - check that you now see version 0.32.1
This fixes:
- when starting the wslServer.sh, no longer runs with
-i, so unexpected commands (such as 'cd', running zsh) in .bash_profile no longer interfere. - inside wslServer.sh, starts the server with the user configured shell (and
-i)
See https://medium.com/@vinhp/set-and-use-zsh-as-default-shell-in-wsl-on-windows-10-the-right-way-4f30ed9592dc on how to configure a shell in wsl
Please let me know if that solves the issues.
My .bashrc had cd ~ just made a clean .bashrc and it finally worked.
I have the same problem, had to remove cd /mnt/c/code for made it working.
Not necessarily because of cd in .bashrc or .bash_profile. If you installed VSCode in a removable drive (this can happen considering that many budget Win10 books have only 32G C:), it would fail the installation of wslServer because when wsl starts, it cannot start from any folder not in a fixed drive even if you have already added the drive in /etc/fstab. As such bash goes to your home folder instead of the extension folder. It of course cannot find wslServer.sh.
Move the whole VSCode Application to C: can definitely solve the issue although it is not recommended. Alternatively, user can change the wslDaemon.js file in the extension_folder/dist/ directory. Add cd your_extension_folder_absolute_path && in front of ./scripts (there are two .scripts found in my wslDaemon.js) and it should work.
I have the same problem on WSL 2 without changing anything... Code-insiders is installed in the default path, etc. It was working fine yesterday, turned the laptop off and on and now it gives the error.
Version: 1.36.0-insider (user setup) Commit: b7265738444f1eee05762341b4361ee6452a4154 Date: 2019-06-27T05:22:06.378Z Electron: 4.2.5 Chrome: 69.0.3497.128 Node.js: 10.11.0 V8: 6.9.427.31-electron.0 OS: Windows_NT x64 10.0.18922
[2019-06-27 12:12:28.090] Windows build: 18922. Multi distro support: enabled
[2019-06-27 12:12:28.308] Launching C:\WINDOWS\System32\wsl.exe -d Ubuntu bash -c
"'./scripts/wslServer.sh' 'b7265738444f1eee05762341b4361ee6452a4154' 'insider'
'.vscode-server-insiders' 'C:/Users/henry/AppData/Local/Temp/vscode-remote-
wsl/b7265738444f1eee05762341b4361ee6452a4154/vscode-server-linux-x64.tar.gz'
" in c:\Users\henry\.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.38.3
[2019-06-27 12:12:28.604] bash: ./scripts/wslServer.sh: No such file or directory```