How to Install Visual Studio Code on Rocky Linux 9 or 8

Installing Visual Studio Code (VS Code) on Rocky Linux 9 and 8 is a straightforward process that unlocks a versatile and powerful development environment for your projects. As an open-source, lightweight, and feature-packed editor, VS Code is a favorite among developers for tasks ranging from web development to systems programming.

Rocky Linux users, particularly those in enterprise or cloud environments, can benefit significantly from VS Code’s robust tools for coding, debugging, and integrating with Git—all while running efficiently on a stable Linux platform. Its flexibility makes it an essential tool for modern development workflows.

By the end of this guide, you’ll not only have Visual Studio Code installed but also a clear understanding of how to tailor it to meet your specific development needs.

Why Visual Studio Code for Rocky Linux?

VS Code’s lightweight design ensures smooth performance on Rocky Linux, even in resource-constrained environments. Its extensibility allows developers to add tools and languages specific to Linux-based development, including Bash scripting, Python, and Docker integration, making it an ideal choice for Rocky Linux users.

Key Features of Visual Studio Code

Visual Studio Code offers an unparalleled development experience. Below are the standout features tailored to meet the needs of Rocky Linux developers:

  • Intelligent Code Completion
    Streamline your coding with advanced suggestions tailored to the syntax and structure of your programming language.
  • Integrated Debugging Tools
    Troubleshoot your applications with built-in debugging support, offering breakpoints, variable inspection, and call stack navigation.
  • Built-in Git Integration
    Manage version control directly within VS Code, from staging changes to resolving merge conflicts, without switching to external tools.
  • Customizable Extensions
    Adapt your development environment with extensions for everything from syntax highlighting to Docker management, perfect for Linux workflows.
  • Optimized Performance for Linux
    Enjoy a seamless experience on Rocky Linux, with efficient resource usage that doesn’t compromise functionality.

Whether you’re managing cloud-based applications or developing locally on Rocky Linux, these features ensure an efficient, productive coding environment.

Update Your Rocky Linux System

Before installing Visual Studio Code, it’s essential to update your system. This ensures that all system components are up-to-date and minimizes potential conflicts during the installation process.

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 Microsoft Visual Studio Code Repository

Visual Studio Code is not included in Rocky Linux’s default repositories. To install it, you need to add Microsoft’s official repository.

Import the Microsoft GPG Key

The Microsoft GPG key authenticates the packages you’ll download 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. 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.

Verify the Repository

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

sudo dnf repolist

If the repository is set up correctly, you’ll see an entry labeled vscode. Once confirmed, you can proceed to the installation.

Install Visual Studio Code on Rocky Linux

After setting up the repository, you can install Visual Studio Code using the DNF package manager.

Install the Stable Version

The stable version is recommended for most users. It provides reliable performance and features. To install it, use this command:

sudo dnf install code

Install the Insider Version

If you prefer the latest features, you can install the insider version. Be aware that this version may be less stable. 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.

Launch Visual Studio Code

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.

Managing Visual Studio Code on Rocky Linux

After installing Visual Studio Code, managing updates and removal is essential to ensure your system remains efficient and secure. This section explains how to update Visual Studio Code to its latest version and how to uninstall it if needed.

Keeping Visual Studio Code Updated

Regular updates are critical to maintaining the performance, security, and functionality of Visual Studio Code. Updates often include bug fixes, new features, and important security patches.

Updating All System Packages, Including Visual Studio Code

To ensure Visual Studio Code and all other installed packages are up to date, use the following command:

sudo dnf upgrade --refresh

This command refreshes repository metadata and upgrades all system packages to their latest versions. It’s a good practice to run this command periodically to keep your system secure and efficient.

Updating Visual Studio Code Only

If you want to update Visual Studio Code specifically, you can use this command:

sudo dnf upgrade code

If you installed the insider version, update it using:

sudo dnf upgrade code-insiders

These commands ensure you are running the latest version of Visual Studio Code while avoiding unnecessary updates to other system components.

Removing Visual Studio Code

You might need to uninstall Visual Studio Code for several reasons, such as troubleshooting or switching to another editor. Follow the steps below to remove Visual Studio Code 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, consider removing the Microsoft repository to avoid unnecessary update checks. Use the following command to delete the repository file:

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

This step is optional but recommended if you do not plan to reinstall Visual Studio Code in the future. It helps keep your system clean and reduces the number of repositories the package manager checks during updates.

Frequently Asked Questions (FAQs)

What should I do if the Microsoft repository is not accessible?

If the Microsoft repository cannot be accessed, check your internet connection first. Then, verify that the repository URL in /etc/yum.repos.d/vscode.repo is correct. You can also try refreshing the repository cache using sudo dnf clean all and sudo dnf update.

Why doesn’t Visual Studio Code launch after installation?

If Visual Studio Code doesn’t launch after installation, check that the installation completed successfully by running sudo dnf list installed | grep code. If it’s installed, verify your PATH environment variable is correctly set by typing echo $PATH. If issues persist, reinstall the application or check for dependency errors.

Can I install Visual Studio Code on Rocky Linux without root access?

Installing Visual Studio Code through DNF requires root access since it modifies system-wide repositories and packages. However, you can use the tarball version available from the official Visual Studio Code website if you do not have root access.

What is the difference between the stable and insider versions of Visual Studio Code?

The stable version of Visual Studio Code is tested and reliable, ideal for most users. The insider version includes the latest features and updates but may be less stable. Choose the version that best suits your needs based on your preference for stability or access to cutting-edge features.

Can I use Visual Studio Code on Rocky Linux for remote development?

Yes, Visual Studio Code supports remote development through the “Remote – SSH” extension. This allows you to connect to remote Rocky Linux machines and develop directly on them. Install the extension via the Extensions Marketplace, and configure your SSH settings to start coding remotely.

Conclusion

By following this guide, you’ve successfully installed and configured Visual Studio Code on Rocky Linux 9 or 8. With its versatile features and extensive customization options, Visual Studio Code provides a powerful platform for all your development needs.

Remember to regularly update Visual Studio Code to access the latest features and security improvements. If you encounter any issues, consult the official Visual Studio Code Documentation or Rocky Linux community resources for support.

We’d Love to Hear From You
Have you customized Visual Studio Code for a specific project on Rocky Linux? Encountered any challenges during installation? Share your experiences, tips, or questions in the comments below. Your insights might help others in the community!

Leave a Comment