Search code examples
visual-studio-codevscode-remote

How to change vscode-server directory


I am trying to use vscode remote ssh extension and connect to Linux machine that has access to my files. Vscode install the server on the Linux machine under user home directory where due to company policy I have very limited quota . Is there a way to configure vscode to install sever in other location ?


Solution

  • Unfortunately there is no direct way yet with VSCode to install into a custom directory. You could follow below steps to move or install it manually into a different directory.

    If your initial installation is successful

    1. Navigate to a desired project space directory from remote desktop terminal

      $ cd /your/big/disk/project/space

    2. Move vscode-server to this area

      $ mv ~/.vscode-server .

    3. Create symlink of .vscode-server in your home directory. Use absolute paths in this command to avoid cyclic links.

      $ ln -s /your/big/disk/project/space/.vscode-server ~/.vscode-server

    4. Confirm no cyclic links with below command, it should not return anything.

      $ find -L ./ -mindepth 15

    5. Reconnect from your VSCode again. Now when VSCode looks for the remote sever in your home directory, it would be redirected to the different directory seamlessly.

    If your initial installation fails (for reasons like cannot extract vscode-server on remote system due to space restriction). I had to make it work this way.

    1. Get vscode-server commit ID on remote server using below command, which would be like 'e2d4cc38bb5da82wb67q86fd50f84h67bb340987'. Replace $COMMIT_ID with your actual commit ID from here on.

      $ ls ~/.vscode-server/bin

    2. Download tarball replacing $COMMIT_ID with the commit number from the previous step on local system. Or, if you have outbound connectivity on remote system, you could directly download it there and skip step 3.

      https://update.code.visualstudio.com/commit:$COMMIT_ID/server-linux-x64/stable

    3. Move tarball to remote server disk from local system. Below command puts it in home dir of remote system.

      $ scp -P 22 vscode-server-linux-x64.tar.gz remoteID.remote.system.url.com:~/

    4. Move tarball to large free space directory as below:

      $ mkdir -p /your/big/disk/project/space/.vscode-server/bin/$COMMIT_ID/

      $ mv ~/vscode-server-linux-x64.tar.gz /your/big/disk/project/space/.vscode-server/bin/$COMMIT_ID/

    5. Extract tarball in this directory

      $ cd /your/big/disk/project/space/.vscode-server/bin/$COMMIT_ID

      $ tar -xvzf vscode-server-linux-x64.tar.gz --strip-components 1

    6. Create symlink of .vscode-server in your home directory. Use absolute paths in this command to avoid cyclic links.

      $ ln -s /your/big/disk/project/space/.vscode-server ~/.vscode-server

    7. Confirm no cyclic links with below command, it should not return anything.

      $ find -L ./ -mindepth 15

    8. Connect again. Now when VSCode looks for the remote sever in your home directory, it would be redirected to the different directory seamlessly.