I'm using the vscode remote tunnels, which I believe are a relatively new feature. When I follow the instructions here, and connect to the tunnel, the .vscode-server
directory gets installed in the root directory on the remote machine, but I would like it to be installed in a specific directory- ideally with a setting similar to the remote.SSH.serverInstallPath
.
I know there is the cli option --cli-data-dir
for the code tunnel
command, but despite specifying this and the remote.SSH.serverInstallPath
for the corresponding host it still installs in the root directory. I'm not sure if I'm missing some setting or if this just isn't available yet.
I came across this issue when I was trying to make the VS Code Tunnel use the same VS Code server as VS Code Remote - SSH uses.
I ended up writing the following shell script wrapper to invoke code tunnel
:
#!/bin/sh -e
export VSCODE_AGENT_FOLDER='<serverInstallPath>/.vscode-server' # (1)
export VSCODE_CLI_DATA_DIR="$VSCODE_AGENT_FOLDER/cli" # (2)
exec code tunnel "$@"
Footnotes:
<serverInstallPath>
with the actual path you specified in remote.SSH.serverInstallPath
.<serverInstallPath>/.vscode-server/cli
, which appears to be created as an empty subdirectory of <serverInstallPath>/.vscode-server
when using VS Code Remote - SSH.This solution allows the VS Code Remote - SSH and VS Code Tunnel servers to share the same user data and extensions. However, the actual paths for the VS Code server installations themselves will differ (e.g., <serverInstallPath>/.vscode-server/cli/servers/Stable-1a5daa3a0231a0fbba4f14db7ec463cf99d7768e/server
for VS Code Tunnel vs. <serverInstallPath>/.vscode-server/bin/1a5daa3a0231a0fbba4f14db7ec463cf99d7768e
for VS Code Remote - SSH). I don't think this should cause any issues.
Both the VS Code Remote - SSH and the VS Code Tunnel features are using the same underlying feature, the VS Code server.
When you use VS Code Remote - SSH, you can specify a path using the remote.SSH.serverInstallPath
setting on the VS Code client, which defaults to ~
. Then:
code
executable, libraries, etc.) is installed within <serverInstallPath>/.vscode-server/bin
, e.g., ~/.vscode-server/bin/1a5daa3a0231a0fbba4f14db7ec463cf99d7768e
.<serverInstallPath>/.vscode-server/data
and <serverInstallPath>/.vscode-server/extensions
, respectively, i.e., ~/.vscode-server/data
and ~/.vscode-server/extensions
by default.
remote.SSH.serverInstallPath
is set, the VS Code Remote - SSH extension sets the environment variable VSCODE_AGENT_FOLDER
to <serverInstallPath>/.vscode-server
within the SSH session before starting the VS Code server. This environment variable is read by vs/server/node/server.main.ts to determine the --user-data-dir
and --extensions-dir
arguments for the VS Code server.For VS Code Remote - SSH, these locations are all controlled by the one setting remote.SSH.serverInstallPath
.
For the VS Code Tunnel, these locations are controlled in two different ways.
<CLI data directory>/servers
, e.g., ~/.vscode/cli/servers/Stable-1a5daa3a0231a0fbba4f14db7ec463cf99d7768e/server
.
~/.vscode/cli
, but it can be set by the --cli-data-dir
command-line argument to code tunnel
or by the VSCODE_CLI_DATA_DIR
environment variable.~/.vscode-server/data
and ~/.vscode-server/extensions
by default, and there is no explicitly documented way to change this.
VSCODE_AGENT_FOLDER
to your desired location, resulting in the paths $VSCODE_AGENT_FOLDER/data
and $VSCODE_AGENT_FOLDER/extensions
for the user data and extensions, respectively.