How to Install Visual Studio Code on Rocky Linux

Visual Studio Code is one of the most popular code editors for Linux systems, offering powerful debugging tools, Git integration, and an extensive extension ecosystem. This guide shows you how to install Visual Studio Code on Rocky Linux using Microsoft’s official repository, which ensures you receive automatic security updates through your standard DNF package manager.

Whether you need the stable release for production work or the insider version for extension development, this installation method works identically on Rocky Linux 10, 9, and 8. By the end of this guide, you will have a fully functional VS Code installation with verified repository access and the knowledge to update or remove it cleanly.

Update Your Rocky Linux System

Before installing Visual Studio Code, update your system to ensure all components are current with the latest security patches. This step minimizes potential conflicts during installation and prevents dependency issues that can interfere with package management.

Open a terminal and run the following command to update your Rocky Linux system:

sudo dnf upgrade --refresh

This command refreshes the repository metadata cache and upgrades all installed packages to their latest versions. Wait for the process to complete before proceeding to the next step.

Add the Visual Studio Code Repository on Rocky Linux

Visual Studio Code is not included in Rocky Linux’s default repositories, so you must add Microsoft’s official repository. The process involves importing the GPG key for package verification, creating the repository configuration file, and verifying the setup works correctly.

Import the Microsoft GPG Key

The Microsoft GPG key authenticates packages downloaded from the repository, ensuring they have not been tampered with during transit. Run the following command to import the key into your RPM keyring:

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

Unlike some third-party keys that trigger SHA-1 warnings on Rocky Linux 9 and 10, the Microsoft key imports cleanly without any policy issues. To verify the key was imported successfully, run:

rpm -q gpg-pubkey --qf '%{NAME}-%{VERSION}-%{RELEASE}\t%{SUMMARY}\n' | grep -i microsoft

Successful import produces output confirming the Microsoft key is present:

gpg-pubkey-be1229cf-5631588c	Microsoft (Release signing) <gpgsecurity@microsoft.com> public key

Create the Repository File

Next, create a repository file pointing to Microsoft’s package server. This configuration file tells DNF where to find Visual Studio Code packages and how to verify them. Run the following command:

printf "[vscode]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc\nmetadata_expire=1h\n" | sudo tee /etc/yum.repos.d/vscode.repo

This command creates a configuration file named vscode.repo in the /etc/yum.repos.d/ directory. The repo_gpgcheck=1 setting enables repository metadata verification for additional security, while metadata_expire=1h ensures you see new releases within an hour of their publication.

Install Visual Studio Code on Rocky Linux

Verify the Repository

After creating the repository file, verify that DNF recognizes the new repository by listing all enabled repositories:

sudo dnf repolist

Successful repository verification produces output similar to this example from Rocky Linux 10:

repo id                         repo name
appstream                       Rocky Linux 10 - AppStream
baseos                          Rocky Linux 10 - BaseOS
extras                          Rocky Linux 10 - Extras
vscode                          Visual Studio Code

The vscode entry confirms that DNF can now access the Microsoft repository for Visual Studio Code packages. If you do not see this entry, double-check the repository file syntax using cat /etc/yum.repos.d/vscode.repo before proceeding. For tips on optimizing package manager performance, consult the guide on increasing DNF speed on Rocky Linux.

Choose Your VS Code Version

Microsoft provides two release channels for Visual Studio Code, each targeting different use cases and stability requirements:

  • Stable version (code): Recommended for most users. This version receives monthly feature updates and weekly patch releases, all with thorough testing. Choose this for production development work, team environments, and situations where reliability matters more than having the newest features immediately.
  • Insider version (code-insiders): Daily builds containing the latest features and bug fixes. This version is designed for VS Code extension developers who need to test against upcoming API changes, or users who want early access to experimental features. Expect occasional instability and potential breaking changes between builds.

Both versions can coexist on the same system because they use separate binary names and configuration directories, allowing you to maintain a stable environment for daily work while testing insider features in parallel.

Install Stable Visual Studio Code

The stable version provides reliable performance and thoroughly tested features suitable for production development work. Install it with the following command:

sudo dnf install code

DNF will calculate dependencies and prompt you to confirm the installation. VS Code requires several graphical libraries that may not be present on minimal Rocky Linux installations, so expect the dependency list to include packages for GTK, graphics rendering, and audio support.

After installation completes, verify that VS Code is properly installed by checking the package version:

rpm -q code

The output shows the installed package version:

code-1.107.1-1765982492.el8.x86_64

The version number will reflect the current release at the time of your installation.

Install Insider Visual Studio Code

Alternatively, if you need daily builds with the latest features for extension development or API testing, install the insider version instead. Be aware that this version may contain unstable features and breaking changes between builds:

sudo dnf install code-insiders

During either installation, the system may prompt you to confirm the import of GPG keys if this is your first installation from the Microsoft repository. Review the key fingerprint to ensure it matches Microsoft’s official key before accepting.

Launch Visual Studio Code on Rocky Linux

After installation, you can launch Visual Studio Code through either the terminal or your desktop environment’s graphical interface.

Launch from the Terminal

To open Visual Studio Code from the command line, enter:

code

You can also open a specific file or directory by passing it as an argument. For example, code ~/projects/myapp opens VS Code with that directory as the workspace root. If you installed the insider version, use code-insiders instead:

code-insiders

Launch from the Applications Menu

For a GUI-based approach, open the application menu on your Rocky Linux desktop. Search for “Visual Studio Code” or “VS Code” and click the icon to start the program. On GNOME, you can also press the Super key (Windows key) and type “code” to find the application quickly.

Update Visual Studio Code on Rocky Linux

Visual Studio Code updates automatically through your regular system update workflow. Running a full system upgrade ensures you receive the latest VS Code version along with security patches for all installed packages:

sudo dnf upgrade --refresh

Alternatively, you can update only Visual Studio Code without upgrading other system packages. This approach is useful when you need the latest VS Code features but want to defer broader system updates:

sudo dnf upgrade code

If you installed the insider version, update it using:

sudo dnf upgrade code-insiders

These commands check for newer versions in the Microsoft repository and apply updates only to the specified package while leaving other installed software at their current versions.

Remove Visual Studio Code on Rocky Linux

When you need to uninstall Visual Studio Code for troubleshooting or to switch editors, follow these steps to cleanly remove all VS Code components from your system.

Uninstall the Package

To remove the stable version of Visual Studio Code, run:

sudo dnf remove code

If you installed the insider version instead, remove it with:

sudo dnf remove code-insiders

These commands remove the VS Code binary and associated system files. DNF automatically handles orphaned dependencies by default, so no separate autoremove step is typically needed.

Remove User Configuration and Data

The package removal does not delete your personal VS Code settings, extensions, or cached data. Visual Studio Code stores user data in three main directories:

  • ~/.config/Code – Settings, keybindings, snippets, and state data
  • ~/.vscode – Installed extensions
  • ~/.cache/Code – Cached data and logs

The following commands permanently delete your VS Code settings, extensions, and cached data. If you have custom configurations, snippets, or keybindings you want to preserve, back them up first with cp -r ~/.config/Code ~/vscode-backup.

To remove all user data for the stable version, run:

rm -rf ~/.config/Code ~/.vscode ~/.cache/Code

For the insider version, the directory names differ slightly:

rm -rf ~/.config/Code\ -\ Insiders ~/.vscode-insiders ~/.cache/Code\ -\ Insiders

Remove the Repository

If you do not plan to reinstall VS Code, optionally remove the Microsoft repository to prevent unnecessary metadata checks during future system updates:

sudo rm /etc/yum.repos.d/vscode.repo

After removing the repository, verify the removal succeeded:

dnf repolist | grep vscode

An empty output confirms the repository is no longer active. This keeps your repository list tidy and eliminates unused entries from your package manager configuration.

Troubleshooting Common Issues

When problems occur during installation or daily use, systematic troubleshooting identifies the root cause quickly. The following sections address the most common issues on Rocky Linux with actionable solutions.

VS Code Fails to Start

When VS Code fails to start, launch it from the terminal with verbose output to capture detailed error messages that reveal the underlying problem:

code --verbose

Missing shared library errors typically look like this:

error while loading shared libraries: libxkbfile.so.1: cannot open shared object file: No such file or directory

If you see missing library errors mentioning shared objects (files ending in .so), update your system to resolve the missing dependencies:

sudo dnf upgrade --refresh

For permission-related errors, verify that your user account has proper ownership of the VS Code configuration directories:

ls -la ~/.config/Code
ls -la ~/.vscode

If these directories show ownership by root or another user, reset permissions to your account:

sudo chown -R $USER:$USER ~/.config/Code ~/.vscode

Extension Conflicts and Crashes

Extension conflicts or corruption can prevent VS Code from starting or cause crashes during use. To identify problematic extensions, launch VS Code with all extensions disabled:

code --disable-extensions

If VS Code works normally with extensions disabled, re-enable extensions one at a time through the Extensions panel (Ctrl+Shift+X) to isolate the problematic extension. Once identified, check the extension’s marketplace page or GitHub repository for known compatibility issues with your VS Code version.

For persistent extension issues, you can clear all extensions and reinstall only the ones you need:

rm -rf ~/.vscode/extensions/*

Then reinstall extensions through the VS Code interface or from the command line using the extension identifier from the marketplace page:

code --install-extension ms-python.python

Repository or GPG Key Errors

GPG signature verification failures typically indicate missing or incorrectly imported keys. A common error message looks like:

warning: Signature not supported. Hash algorithm SHA1 not available.
error: https://packages.microsoft.com/yumrepos/vscode/repodata/repomd.xml: GPG verification failed

First, verify that the Microsoft GPG key exists in your RPM keyring:

rpm -q gpg-pubkey --qf '%{NAME}-%{VERSION}-%{RELEASE}\t%{SUMMARY}\n' | grep -i microsoft

If the Microsoft key does not appear in the output, re-import it:

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

Next, verify the repository file syntax is correct:

cat /etc/yum.repos.d/vscode.repo

The output should match this configuration:

[vscode]
name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
metadata_expire=1h

Finally, confirm the repository appears in DNF’s enabled repository list:

dnf repolist | grep vscode

If the repository does not appear, check that enabled=1 is set correctly and that no syntax errors exist in the configuration file.

Additional Help

If none of the above solutions resolve your issue, consult the official VS Code FAQ for additional troubleshooting guidance. You can also post your question on the Rocky Linux forums, where community members and maintainers can provide distribution-specific assistance.

Conclusion

Visual Studio Code provides a powerful and extensible development environment for Rocky Linux systems. The official Microsoft repository ensures consistent security updates through your standard DNF workflow, while support for both stable and insider channels accommodates different development needs. Your Rocky Linux system now runs a professional code editor suitable for application development, infrastructure automation, and system administration tasks.

Leave a Comment

Let us know you are human: