CentOSRHEL Based

How To Install Visual Studio Code on CentOS Stream 10

Install Visual Studio Code on CentOS Stream 10

In this tutorial, we will show you how to install Visual Studio Code on CentOS Stream 10. Visual Studio Code (VS Code) has become an indispensable tool for developers across various platforms. Its versatility, extensive feature set, and robust extension ecosystem make it a top choice for coding enthusiasts and professionals alike. In this guide, we’ll walk you through the process of installing VS Code on CentOS Stream 10, the latest iteration of the popular Linux distribution.

CentOS Stream 10, with its cutting-edge features including Python 3.12 and GCC 14 support, provides an excellent foundation for development work. Pairing this powerful operating system with VS Code creates a formidable development environment. Whether you’re a seasoned developer or just starting your coding journey, this guide will help you set up VS Code efficiently on your CentOS Stream 10 system.

Prerequisites

Before we dive into the installation process, let’s ensure you have everything needed to proceed smoothly:

  • A CentOS Stream 10 system with the latest updates installed
  • A stable internet connection for downloading packages
  • Access to a terminal or command-line interface
  • Sudo privileges on your account for system-wide installations

Ensuring these prerequisites are met will help avoid potential roadblocks during the installation process.

Method 1: Installing via Package Manager

The recommended approach for installing VS Code on CentOS Stream 10 is through the package manager. This method ensures you’re getting the official, up-to-date version directly from Microsoft’s repositories.

Step 1: System Preparation

First, let’s update your system packages to ensure we’re working with the latest versions:

sudo dnf update -y

Next, we need to enable the CodeReady Linux Builder repository, which contains some dependencies required for VS Code:

sudo dnf config-manager --set-enabled crb

Step 2: Import Microsoft GPG Key

To verify the authenticity of the VS Code package, we need to import Microsoft’s GPG key:

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

Step 3: Create Repository File

Now, let’s create a repository file for VS Code. This file tells your package manager where to find the VS Code package:

sudo tee /etc/yum.repos.d/vscode.repo <<EOF
[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

This command creates a file named vscode.repo in the /etc/yum.repos.d/ directory with the necessary repository information.

Step 4: Installation

With the repository set up, we can now install VS Code:

sudo dnf install code

The package manager will download and install VS Code along with any necessary dependencies. Once the installation is complete, you can verify it by checking the installed version:

code --version

Method 2: Installing via RPM Package

If you prefer a more manual approach or need to install VS Code on a system without internet access, you can use the RPM package method.

Step 1: Download the RPM Package

Visit the official Visual Studio Code website and download the latest RPM package for CentOS/RHEL. You can do this directly from your browser or use the wget command in the terminal:

wget https://code.visualstudio.com/sha/download?build=stable&os=linux-rpm-x64 -O vscode.rpm

Step 2: Install the Package

Once the download is complete, install the package using the dnf package manager:

sudo dnf install ./vscode.rpm

This command will install VS Code and resolve any dependencies automatically.

Step 3: Verification

After installation, verify that VS Code is installed correctly by checking its version:

code --version

Post-Installation Setup

Now that VS Code is installed, let’s look at how to launch it and perform some initial configuration.

Launching VS Code

You can start VS Code in two ways:

  1. From the command line, simply type code and press Enter.
  2. Through the graphical interface, navigate to Applications > Programming > Visual Studio Code.

Install Visual Studio Code on CentOS Stream 10

Initial Configuration

When you first launch VS Code, you’ll be greeted with a welcome screen. Here are some initial steps to optimize your setup:

  1. Choose your preferred color theme from File > Preferences > Color Theme.
  2. Install the “Remote – SSH” extension if you plan to work on remote servers.
  3. Set up version control by installing the Git extension if it’s not already included.
  4. Configure your preferred keyboard shortcuts under File > Preferences > Keyboard Shortcuts.

Essential Extensions

VS Code’s true power lies in its extensibility. Here are some must-have extensions for various development tasks:

  • Python: For Python development with features like IntelliSense and debugging.
  • C/C++: Provides language support for C and C++ development.
  • ESLint: Integrates ESLint JavaScript into VS Code for code quality.
  • Docker: Adds support for Docker development.
  • Live Server: Launches a local development server with live reload feature for static and dynamic pages.

To install extensions, click on the Extensions view icon on the Sidebar (or press Ctrl+Shift+X), search for the extension, and click Install.

Troubleshooting Common Issues

Even with a smooth installation, you might encounter some issues. Here are solutions to common problems:

Package Conflicts

If you encounter package conflicts during installation, try the following:

sudo dnf clean all
sudo dnf update
sudo dnf install code --allowerasing

The --allowerasing option allows DNF to remove conflicting packages, but use it cautiously.

Repository Errors

If you see repository errors, ensure your internet connection is stable and try updating the repository cache:

sudo dnf makecache

Launch Issues

If VS Code fails to launch, try running it from the terminal with the --verbose flag to get more information:

code --verbose

This will provide detailed output that can help identify the problem.

Maintaining VS Code

To keep your VS Code installation in top shape, follow these maintenance tips:

Updates and Upgrades

VS Code will automatically check for updates. When prompted, allow it to update to the latest version. Alternatively, you can manually check for updates:

sudo dnf update code

Managing Extensions

Regularly review your installed extensions. Remove unused ones to keep VS Code running efficiently. You can manage extensions from the Extensions view or use the command palette (Ctrl+Shift+P) and type “Extensions: Show Installed Extensions”.

Backup and Recovery

VS Code offers a Settings Sync feature that backs up your settings, keybindings, and extensions to the cloud. Enable this by clicking on the gear icon in the lower-left corner and selecting “Turn on Settings Sync”.

For a manual backup, you can copy the following directories:

  • ~/.config/Code/ for user settings
  • ~/.vscode/extensions/ for installed extensions

Congratulations! You have successfully installed VS Code. Thanks for using this tutorial to install the Visual Studio Code on CentOS Stream 10. For additional help or useful information, we recommend you check the official VS Code website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button