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 integrates seamlessly with Rocky Linux 10, 9, and 8.

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.

To update your Rocky Linux system, open a terminal and run the following command:

sudo dnf upgrade --refresh

This command updates the repository metadata 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 three steps: importing the GPG key for package verification, creating the repository configuration file, and verifying the setup.

Import the Microsoft GPG Key

The Microsoft GPG key authenticates packages downloaded from the repository and ensures they are secure. Use this command to import the key:

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

This step is crucial to ensure the integrity of the Visual Studio Code packages.

Create the Repository File

Next, create a repository file pointing to Microsoft’s server. This configuration file tells DNF where to find Visual Studio Code packages. 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" | sudo tee /etc/yum.repos.d/vscode.repo

This command creates a configuration file named vscode.repo in the /etc/yum.repos.d/ directory. It allows the DNF package manager to access the repository for Visual Studio Code.

Install Visual Studio Code on Rocky Linux

Verify the Repository

After creating the repository file, verify that it has been added successfully by running:

sudo dnf repolist

If the repository is set up correctly, you will see an entry labeled vscode in the output. Once confirmed, you are ready to proceed to the installation. For more information about optimizing DNF performance, you can also consult the guide on increasing DNF speed on Rocky Linux.

Successful repository verification produces output similar to this:

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.

Choose Your VS Code Version

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

  • Stable version (code): Recommended for most users. Receives monthly feature updates and weekly patch releases with thorough testing. Ideal for production development work, enterprise environments, and users who prioritize stability over cutting-edge features.
  • Insider version (code-insiders): Daily builds with the latest features and bug fixes. Use this if you develop VS Code extensions, need to test against upcoming API changes, or want early access to experimental features. Expect occasional instability and breaking changes between releases.

Both versions can coexist on the same system since they use separate configuration directories and binary names. This allows you to maintain a stable environment while testing insider features in parallel.

Install Stable Visual Studio Code on Rocky Linux

The stable version provides reliable performance and thoroughly tested features suitable for production development work. To install it, use this command:

sudo dnf install code

Install Insider Visual Studio Code on Rocky Linux

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

sudo dnf install code-insiders

During the installation, the system may prompt you to confirm the import of GPG keys. Review the details to ensure they match the Microsoft key.

How to Launch Visual Studio Code on Rocky Linux

After installation, you can launch Visual Studio Code either through the terminal or a graphical interface.

Launch from the Terminal

To open Visual Studio Code, enter the following command in the terminal:

code

If you installed the insider version, use:

code-insiders

Launch from the Graphical Interface

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.

Update and Remove Visual Studio Code on Rocky Linux

Regular maintenance keeps Visual Studio Code secure and up to date with the latest features. This section covers updating VS Code to the newest version and cleanly removing it when necessary.

How to Update Visual Studio Code on Rocky Linux

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

Updating Visual Studio Code Only

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 update only VS Code while leaving other system packages at their current versions.

How to 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.

Uninstalling the Stable Version

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

sudo dnf remove code

This command removes Visual Studio Code and its associated files from your system.

Uninstalling the Insider Version

If you are using the insider version, you can uninstall it with:

sudo dnf remove code-insiders

Cleaning Up the Repository

After uninstalling Visual Studio Code, optionally remove the Microsoft repository if you do not plan to reinstall VS Code. This cleanup step keeps your repository list tidy and prevents unnecessary repository checks during future system updates. Remove the repository file using this command:

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

Removing the repository file reduces DNF’s metadata refresh workload during future updates and eliminates unused repository 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 Won’t Launch

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

code --verbose

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

sudo dnf upgrade --refresh

Additionally, for permission-related errors, verify that your user account has write access to the VS Code configuration directory:

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

If these directories show incorrect ownership, reset permissions to your user account:

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

Extension or Update Issues

Extension conflicts or corruption can prevent VS Code from starting or cause crashes during use. First, identify problematic extensions by launching 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.

Alternatively, for persistent extension issues, clear the extension cache and reinstall:

rm -rf ~/.vscode/extensions/*
code --install-extension publisher.extension-name

Replace publisher.extension-name with the actual extension identifier from the marketplace page.

Repository or GPG Key Errors

GPG signature verification failures typically indicate missing or incorrectly imported keys. 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 by checking for common configuration errors:

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

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

sudo dnf repolist | grep vscode

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

Additional Help

If none of the above solutions resolve your issue, consult the official VS Code FAQ or post your question on the Rocky Linux forums, where community members and maintainers can provide additional assistance.

Conclusion

Visual Studio Code delivers a powerful development environment for Rocky Linux systems with enterprise-grade stability and extensive customization through extensions. The official Microsoft repository ensures consistent security updates through your standard DNF workflow, while support for both stable and insider channels accommodates different stability requirements. Your Rocky Linux system now runs a professional code editor suitable for application development, infrastructure automation, and system administration tasks at any scale.

Leave a Comment