How to Install Visual Studio Code on Fedora 40 or 39

Visual Studio Code is a versatile and powerful code editor that has captured the attention of developers worldwide. Its lightweight design and robust features make it an ideal choice for coding, debugging, and web development tasks. With an array of extensions and customization options, Visual Studio Code stands out for its adaptability to various programming languages and development environments.

Here are some key highlights of Visual Studio Code:

  • Cross-platform compatibility: Works seamlessly on Windows, macOS, and Linux.
  • Intuitive interface: Offers a clean, accessible workspace that can be customized to individual preferences.
  • Rich language support: Provides built-in support for a multitude of programming languages.
  • Powerful debugging tools: Includes an integrated debugger to help diagnose and fix issues quickly.
  • Extensible and customizable: Allows users to enhance functionality with extensions and themes.
  • Source control integration: Supports Git out of the box, making version control smoother and more integrated.
  • Intelligent code completion: Features IntelliSense, which provides smart completions based on variable types, function definitions, and imported modules.
  • Remote development capabilities: Directly enables coding on remote machines, containers, and even the Windows Subsystem for Linux (WSL) from the editor.

Now, let’s dive into the technical specifics of installing Visual Studio Code on your Fedora 40 or 39 Linux system.

Method 1: Install Visual Studio Code via RPM

Update Fedora Before Visual Studio Code Installation

Before diving into the installation process, ensuring your Fedora system is up-to-date is crucial. This practice helps avoid potential issues during the installation and keeps your system running smoothly.

To update your Fedora system, open a terminal and execute the following command:

sudo dnf upgrade --refresh

Import Visual Studio Code RPM

Visual Studio Code isn’t available by default in the standard Fedora repositories. However, you can easily set up and import the official Visual Studio Code repository on your system by following these steps:

Import VSCode GPG key:

To verify the authenticity of the installed packages, start by importing the GPG key with this command:

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

Import VSCode RPM Repository:

Next, import the repository using the command below. This command creates a new repository file with the necessary configuration to access the Visual Studio Code packages:

printf "[vscode]\nname=packages.microsoft.com\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 -a /etc/yum.repos.d/vscode.repo

Upon successful execution, you should see the following output in your terminal:

[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

With the repository in place, you can now install Visual Studio Code on Fedora Linux.

Finalize Visual Studio Code Installation

There are two options available: the stable build and the insider build. For most users, we recommend installing the stable build.

Note: You can install both versions of Visual Studio Code stable and insiders build. if you like, they share separate installations.

Option 1: Install VSCode stable build (Recommended)

sudo dnf install code

Option 2: Install VSCode insiders build (upstream)

If you prefer to have access to the latest features and updates with the Visual Studio Insiders edition, you can install the insider build by running the following:

sudo dnf install code-insiders

Note: The first time you install Visual Studio Code, you should see the GPG key being imported, as shown in the example below:

Importing GPG key 0xBE1229CF:
 Userid     : "Microsoft (Release signing) <gpgsecurity@microsoft.com>"
 Fingerprint: BC52 8686 B50D 79E3 39D3 721C EB3E 94AD BE12 29CF
 From       : https://packages.microsoft.com/keys/microsoft.asc

Install Visual Studio Code via Flatpak and Flathub

This secondary section provides instructions on installing Visual Studio Code on Fedora Linux utilizing Flatpak and the Flathub repository, showcasing an alternative to the conventional DNF method.

Enable Flathub for Visual Studio Code

First, ensure your system includes the Flathub repository, which houses various applications, including Visual Studio Code. If not already added, use the command below to add the Flathub repository to Flatpak:

flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

Install Visual Studio Code via Flatpak Command

With Flatpak and Flathub now operational, advance to the installation of Visual Studio Code by dispatching the following command:

flatpak install flathub com.visualstudio.code

This command commences a search for the Visual Studio Code package within the Flathub repository and triggers its installation on your system.

Troubleshooting Flathub Activation on Fedora Linux

It might not activate as expected in some scenarios despite having imported Flathub on Fedora Linux.

To rectify this, enter the following command to enable Flathub:

flatpak remote-modify --enable flathub

Launch Visual Studio Code User Interface

Congratulations on successfully installing Visual Studio Code! Now, it’s time to launch the application and explore its features. Depending on your preferences, there are several ways to open Visual Studio Code.

CLI Methods to Launch VSCode

For those who prefer using the command line terminal, you can quickly launch Visual Studio Code with the following commands:

stable build, run the following:

code

insiders build, execute the following:

code-insiders

Alternatively, Flatpak installations need to run the alternative flatpak run command for VSCode:

flatpak run com.visualstudio.code

GUI Method to Launch VSCode

If you’re a desktop user who prefers not to use the command line terminal, you can easily open Visual Studio Code through the GUI. Here’s how:

  1. Click on the Activities button located in the top-left corner of your screen.
  2. Select Show Applications (represented by a grid icon) to display a list of installed applications.
  3. Find and click on the Visual Studio Code icon to launch the application.

Additional Visual Studio Code Commands

Update Visual Studio Code

It’s essential to keep Visual Studio Code up-to-date for the best performance and security. To check for updates across all DNF packages, including Visual Studio Code, use the following command:

sudo dnf update --refresh

Alternatively, for the Flatpak equivalent command to blanket check all Flatpak installations for updates, run the following command:

flatpak update

Remove Visual Studio Code

DNF Remove Method For Visual Studio Code

Suppose you no longer need Visual Studio Code or wish to switch to a different version. In that case, you can uninstall it using the appropriate command based on your installation:

sudo dnf remove code
sudo dnf remove code-insiders

If you’re sure you won’t reinstall Visual Studio Code in the future, you can also remove the repository from your system. To do this, execute the following command:

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

Flatpak Remove Method For Visual Studio Code

Alternatively, if you installed VSCode utilizing Flatpak, use the following command to remove it:

flatpak uninstall com.visualstudio.code

Closing Thoughts

We’ve walked through installing Visual Studio Code on Fedora 40 or 39. Remember, the power of VS Code lies in its flexibility and customization options, so don’t hesitate to personalize your workspace and explore the vast array of extensions available. Experiment with the features and settings to find the best for your coding style. Happy coding!

Useful and Relevant Links

Here are some valuable links related to using Visual Studio Code:

Joshua James
Follow me