microsoft / microsoft/vscode-remote-release
WSL2: make VS Code Server work with automount disabled
@aeschli is already working on this.
Since Oct 24, 2021.
- Dominant language
- Dockerfile
- Stars
- 4.2k
- Forks
- 470
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
If you disable automounting of Windows partitions in WSL2 (you can have reasons to do that) through creating
/etc/wsl.conf
[automount]
enabled=false
… the VS Code will then fail to start since it can't copy it's server file from /mnt/c/Users/username/AppData/Local/Temp/vscode-remote-wsl/, since Windows partitions are never mounted.
‘More details’ from terminal
[2021-10-24 11:55:23.002] Resolving wsl+ubuntu-mastodon, resolveAttempt: 1
[2021-10-24 11:55:23.077] Starting VS Code Server inside WSL (ubuntu-mastodon)
[2021-10-24 11:55:23.077] Extension version: 0.58.2, Windows build: 19042. Multi distro support: available. WSL path support: enabled
[2021-10-24 11:55:23.077] No shell environment set or found for current distro.
[2021-10-24 11:55:23.225] Probing if server is already installed: C:\Windows\System32\wsl.exe -d ubuntu-mastodon -e sh -c "[ -d ~/.vscode-server/bin/6cba118ac49a1b88332f312a8f67186f7f3c1643 ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2021-10-24 11:55:23.345] Probing result: found
[2021-10-24 11:55:23.345] Server install found in WSL
[2021-10-24 11:55:23.345] Launching C:\Windows\System32\wsl.exe -d ubuntu-mastodon sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" 6cba118ac49a1b88332f312a8f67186f7f3c1643 stable .vscode-server 0 '}
[2021-10-24 11:55:23.461] sh: 1: /scripts/wslServer.sh: not found
[2021-10-24 11:55:23.462] VS Code Server for WSL closed unexpectedly.
[2021-10-24 11:55:23.462] For help with startup problems, go to
[2021-10-24 11:55:23.462] https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips
[2021-10-24 11:55:23.486] WSL Daemon exited with code 0
I think this can be worked around by accessing WSL filesystem through \\wsl$\distro-name\ and copying WSL scripts over to ~/.vscode-server/scripts (or if it's overwritten with every update of code-server, then maybe in some other directory like ~/.local/lib/vscode-server?) and chmod +x them (there can be a better way, perhaps?), then instead of running them from /mnt/c/..., just execute them from the directory copied. I actually was able to start the server that way:
Command log
... files copied through explorer here ...
chmod +x ~/.vscode-server/scripts/wslServer.sh
chmod +x ~/.vscode-server/scripts/wslDownload.sh
chmod +x ~/.vscode-server/scripts/wslCode.sh
~/.vscode-server/scripts/wslServer.sh 6cba118ac49a1b88332f312a8f67186f7f3c1643 stable .vscode-server 0
Setting up server environment: Looking for /home/braw/.vscode-server/server-env-setup. Not found.
WSL version: 5.10.16.3-microsoft-standard-WSL2 ubuntu-mastodon
WSL2-shell-PID: 299
Starting server: /home/braw/.vscode-server/bin/6cba118ac49a1b88332f312a8f67186f7f3c1643/server.sh --port=0 --use-host-proxy --without-browser-env-var --disable-websocket-compression --print-ip-address --enable-remote-auto-shutdown
*
* Visual Studio Code Server
*
* Reminder: You may only use this software with Visual Studio family products,
* as described in the license https://aka.ms/vscode-remote/license
*
IP Address: 172.18.89.65
Extension host agent listening on 32987
[19:09:50] Extension host agent started.
Although VS Code still wouldn't connect to it (maybe detecting running server isn't a part of the script).
Don't really know how internals work, so this is just a guessing, but I think you get the concept of that idea! :D
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.