vscode-remotevscode-remote-ssh

VSCode-Remote Tunnels Server Install Path


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.


Solution

  • 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:

    1. This points my user data and extensions for the VS Code Tunnel server to the same user data and extensions used by the VS Code Remote - SSH server. Of course, replace <serverInstallPath> with the actual path you specified in remote.SSH.serverInstallPath.
    2. This points the CLI data directory to the <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.

    Explanation

    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:

    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.