How To Install Vscode On Linux

How To Install Vscode On Linux

Reading time1 min
#Linux#Programming#Software#VSCode#VisualStudioCode#LinuxDistros

Mastering VSCode Installation on Linux: Reliable Setup by Distribution

VSCode is the de facto lightweight IDE for polyglot development, but installation nuances on Linux still trip up engineers deploying workstations or CI runners. Below: distribution-specific install methods that ensure reliable updates, proper extension support, and minimize integration headaches.


Distribution Detection

First step: know your package manager.

  • Debian/Ubuntu/Mint/Pop!_OS: apt (.deb pkgs)
  • Fedora/RHEL/CentOS: dnf or yum (.rpm pkgs)
  • Arch/Manjaro: pacman or AUR helper
  • Other flavors: see VSCode documentation, but most derive from these.

Debian-based (apt): Official Repo for Easy Updates

Critically: Use Microsoft’s APT repo. Deb packages downloaded manually do not auto-update.

Add Microsoft’s GPG Key and Repo

curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /usr/share/keyrings/microsoft.gpg > /dev/null
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main" | sudo tee /etc/apt/sources.list.d/vscode.list

If running a non-standard architecture (e.g. ARM64), use arch=arm64.

Update Index and Install

sudo apt update
sudo apt install code

Alternative: Manual .deb Download

Used when air-gapped or for scripting simplicity (at the cost of updates):

wget -O vscode.deb "https://update.code.visualstudio.com/latest/linux-deb-x64/stable"
sudo apt install ./vscode.deb
# Don’t forget to remove the installer to keep /tmp clean.
rm vscode.deb

Red Hat-based (dnf/yum): Persistent, Signed Repo

Import Microsoft GPG Key and Create Repo

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
cat <<EOF | sudo tee /etc/yum.repos.d/vscode.repo
[code]
name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
EOF

Install (Fedora ≥22, CentOS 8+)

sudo dnf check-update
sudo dnf install code

Older systems (yum):

sudo yum check-update
sudo yum install code

Note: SELinux-enabled distributions may require additional policy configuration for some extensions that operate on the filesystem.


Arch Linux: Official Package or AUR Variant

  • Check official community repo first:

    sudo pacman -Sy code
    

    If unavailable or if proprietary features required (tracking, telemetry, branding differences):

    yay -S visual-studio-code-bin
    

    Note: visual-studio-code-bin pulls Microsoft binaries; code is the arch community build. Expect minor discrepancies in extension syncing and authentication support.


Alternative: Snap Package

Not recommended for latency-sensitive workloads—Snap start-up times are typically 1–2x slower and filesystem isolation can break e.g. Docker CLI or language server integrations. Still, if consistency across distros outweighs those disadvantages:

sudo snap install --classic code

Launch and Integrate

Launch VSCode in the current directory:

code .

To register code:// URLs system-wide, log out/in after install (GNOME, KDE only).
For remote development, validate Docker or SSH extension compatibility—Snap/Flatpak users, in particular, may need to set up additional interface connections.


Common Problems and Observed Edge Cases

SymptomDiagnosticResolution
E: Unable to locate package codeAPT index not current or repo misconfiguredsudo apt update and re-add repo
GPG error:... NO_PUBKEY ...Key import failureRe-import, verify /usr/share/keyrings
Extensions fail to install or updateNetwork/firewall restrictions or Snap confinementTry classic repo, check proxy configuration
Segmentation fault (core dumped) on launchMismatched GLib version (noted on Ubuntu 18.04)Update OS, purge/reinstall code
Cannot debug Node/Python inside containersSELinux/AppArmor or Snap confinementUse system package, adjust policies

See $HOME/.config/Code/logs/ for detailed runtime logs.


Non-Obvious Tip: Headless and CI Usage

For CI/CD tasks or X11-free servers, VSCode’s CLI is functional for extension management:

code --install-extension ms-python.python --force
code --list-extensions
code --uninstall-extension ms-vscode.cpptools

Useful for pre-provisioning dev containers or ephemeral runners.


Real-World Tradeoff

While Flatpak and Snap enable easier rollbacks and sandboxing, most professional engineers rely on native package installations for maximum compatibility with OS-level features (file watchers, shell registrations, hardware-accelerated rendering).
Yes, Snap works, but if you hit weird bugs—start by switching to the native package.


Confident installs lead to predictable builds and fewer roadblocks. The difference often becomes clear only at scale, or under tight integration requirements. Plan accordingly.


Key dependencies as of 1.89.0 (2024):

  • Electron 27.x
  • Node.js 18.x runtime
  • Strongly advised: glibc ≥ 2.28, GTK 3.22+
  • For remote SSH or Docker: openssh-client, docker CLI available in PATH.

For advanced workspace Bootstrap (multi-user machines, ephemeral VMs), consider exporting your VSCode settings and extensions for automation. Details: code --help and Microsoft’s CLI docs.


Summary: Installation is trivial—unless it isn’t. Use the native repo for your distribution and you’ll rarely have to think about it again.