-
-
Notifications
You must be signed in to change notification settings - Fork 104
Running VS Code server for WSL inside genie bottle
NOTE: A feature request has been submitted to VS Code at https://github.com/microsoft/vscode-remote-release/issues/5145 to make this a configuration item rather than a hack. We need 10 votes before 8th August, 2021 to make the feature request into their backlog. Please vote if this feature helps you!
When running code
from WSL, the VS Code server is always launched outside the bottle even if the code
command is called inside the bottle. This may be inconvenient in some cases, such as not being able to execute systemctl
commands inside a VS Code console.
Here is a hack I currently use to run VS Code server inside the bottle. Go to %USERPROFILE%\.vscode\extensions\
(on Windows) and find the folder with name ms-vscode-remote.remote-wsl-*
where *
is usually a version number. There could be multiple versions of the extension stored. Pick the newest version. Then navigate to scripts
folder. There should be three files under the folder, called wslServer.sh
, wslCode.sh
and wslDownload.sh
respectively. Prepend the following lines to wslServer.sh
:
# Check if inside bottle
if command -v genie > /dev/null && ! genie -b > /dev/null; then
# Rerun current script inside bottle
exec genie -c "$0" "$@"
fi
Then execute wsl --shutdown
and restart VS Code in case the VS Code server is already running inside WSL. Next time the VS Code server is launched, it will be inside the bottle and systemd
will have PID 1.