Installing Visual Studio Code on Rocky Linux EL8 and EL9
Ever tried installing VS Code on Rocky Linux and felt like you’d need a PhD in package management? This guide gets you there fast, covering both the 8‑year‑old EL8 and the newer EL9. No fancy repo tricks or Snap headaches—just straight‑up RPMs that keep your system lean.
Step 1: Grab Microsoft’s GPG Key
The key verifies the package’s authenticity so you’re not downloading a malicious drop‑in replacement.
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
If you see “key already imported,” that’s fine—skip to the next step.
Step 2: Add the VS Code Repository
The repository tells dnf where to look for the latest stable build and handles updates automatically.
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
Step 3: Refresh Metadata & Install
dnf pulls down the repo data, ensuring you get a genuine package instead of an old cached copy.
sudo dnf check-update # updates metadata sudo dnf install code -y
If you’re on EL8 and hit “No matching packages found,” add the “el8” sub‑repo:
sudo tee /etc/yum.repos.d/vscode-el8.repo <<'EOF' [code] name=Visual Studio Code for EL8 baseurl=https://packages.microsoft.com/yumrepos/vscode/el8/ enabled=1 gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.asc EOF sudo dnf install code -y
Step 4: Verify the Installation
code --version
You should see something like 1.95.2 or whatever the latest is. If you’re seeing “command not found,” check that /usr/bin/code exists:
ls -l /usr/bin/code
Step 5 (Optional): Set Up Desktop Launcher
A quick icon makes launching VS Code from your app menu painless.
cat <<EOF | sudo tee /usr/share/applications/vscode.desktop [Desktop Entry] Name=Visual Studio Code Comment=Text editor with debugging support Exec=/usr/bin/code %F Icon=code Terminal=false Type=Application Categories=Utility;Development; StartupNotify=true MimeType=text/plain;text/x-python; EOF
A Real‑World Glitch I’ve Seen
I once had a teammate on Rocky EL9 who tried installing the .deb from Ubuntu’s official site. The package installed, but code launched and immediately froze with a “cannot find libv8” error because the Debian build bundled libraries that don’t exist in Rocky’s base repo. Switching to the Microsoft RPM fixed everything in one go.
Quick FAQ
- Do I need to enable EPEL? No. VS Code is provided directly by Microsoft; EPEL isn’t required.
- Can I use Snap on Rocky Linux? Snap isn’t enabled out of the box, and even if you install it, VS Code’s official Snap package isn’t maintained for RHEL‑based distros.
- Will dnf upgrade update VS Code automatically? Yes—once the repo is added, regular system updates will bump VS Code too.
Give that a whirl and let me know if anything feels off. Happy coding!