Skip to content

Instantly share code, notes, and snippets.

@fanurs
Last active February 9, 2024 17:03
Show Gist options
  • Save fanurs/775842f91c33652521023d30dc2a3ebe to your computer and use it in GitHub Desktop.
Save fanurs/775842f91c33652521023d30dc2a3ebe to your computer and use it in GitHub Desktop.
How to reinstall VS Code remotely
# When to reinstall?
# - When VS Code cannot connect to remote server via the SSH extension
# - New extensions cannot be installed on remote server
# 1. Connect to remote server (without using VS Code, of course).
# 2. Remove the ~/.vscode-server directory
cd ~
rm -rf .vscode-server/
# 3. If some device or resource is busy, e.g.
# "rm: cannot remove '.vscode-server/bin/e180050f1329e81732535dc0e47cfb0b5/.nfs0000000a180e70000f0': Device or resource busy"
# Identify the process ID and kill all associated node processes
# COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
# node 12345 fanurs txt REG 0,55 76304074 2722304381 .vscode-server/bin/e180050f1329e81732535dc0e47cfb0b5/.nfs0000000a180e70000f0
lsof +D .vscode-server/
kill 12345
# If there are many processes, you kill all of them by
kill $(lsof -ti +D .vscode-server/) # -ti removes the header
# 4. You should now be able to remove the directory.
rm -rf .vscode-server/
# 5. Connect to server using VS Code again. A new .vscode-server/ will be installed upon logging in.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment