Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 251
dvir libhaber Avatar asked Jun 27 '20 17:06

dvir libhaber


People also ask

How do I change the directory in VS Code?

The File > Add Folder to Workspace command brings up an Open Folder dialog to select the new folder. Once a root folder is added, the Explorer will show the new folder as a root in the File Explorer. You can right-click on any of the root folders and use the context menu to add or remove folders.

What is VS Code server directory?

The Visual Studio Code Server is a service you can run on a remote development machine, like your desktop PC or a virtual machine (VM). It allows you to securely connect to that remote machine from anywhere through a vscode. dev URL, without the requirement of SSH.

Is it okay to delete VS Code server?

vscode-server in your home directory on the server becoming corrupted in some way. Since VS Code will automatically recreate that directory when you reconnect, it's safe to delete it.


2 Answers

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.

like image 50
sgX Avatar answered Sep 29 '22 02:09

sgX


This has been worked out in the new version of vs-code here here, change the variable remote.SSH.serverInstallPath through settings. Example (from tankahabir's comment)

"remote.SSH.serverInstallPath": {
    "work": "/test/location",
    "home": "/foobar"
}
like image 34
Praharsh Suryadevara Avatar answered Sep 29 '22 03:09

Praharsh Suryadevara