FedoraRHEL Based

How To Install Visual Studio Code on Fedora 42

Install Visual Studio Code on Fedora 42

Visual Studio Code has become one of the most popular code editors among developers worldwide. This lightweight yet powerful editor offers excellent features for programming in multiple languages while maintaining high performance. As Fedora 42 continues to gain popularity among Linux users, knowing how to properly install and configure VS Code on this distribution is essential for developers. This comprehensive guide will walk you through various installation methods, configuration options, and tips to optimize your coding experience on Fedora 42.

Table of Contents

What is Visual Studio Code?

Visual Studio Code, commonly known as VS Code, is a free, open-source code editor developed by Microsoft. Despite being created by Microsoft, VS Code is fully compatible with Linux distributions, including Fedora. It combines the simplicity of a text editor with powerful developer tools such as debugging capabilities, intelligent code completion, syntax highlighting, and Git integration.

What makes VS Code stand out is its extensibility. The editor can be customized with thousands of extensions that add support for various programming languages, frameworks, and tools. These extensions transform VS Code from a simple editor into a full-fledged integrated development environment (IDE) tailored to your specific needs.

VS Code is built on Electron, making it cross-platform compatible while maintaining a consistent experience across different operating systems. The open-source nature of VS Code (released under the MIT license) has contributed significantly to its widespread adoption, though Microsoft does offer proprietary builds with additional features.

System Requirements and Prerequisites

Before installing Visual Studio Code on Fedora 42, ensure your system meets the minimum requirements and you have completed the necessary preparations:

Hardware Requirements:

  • Processor: 1.6 GHz or faster processor
  • RAM: At least 1GB (2GB recommended for a smoother experience)
  • Disk space: Minimum 500MB of free space
  • Display: 1024×768 resolution

Software Prerequisites:

  • Fedora 42 with the latest updates applied
  • Internet connection for downloading VS Code and extensions
  • Sudo privileges for system-wide installation

To verify your system is up to date, open a terminal and run:

sudo dnf update

This command ensures all your packages are updated to their latest versions, reducing the chance of dependency issues during the VS Code installation.

Preparing Your Fedora 42 System

Proper preparation before installation helps prevent common issues and ensures a smooth setup process. Let’s go through the essential preparation steps:

Update Package Repositories

First, make sure your system’s package repositories are up to date:

sudo dnf check-update

Check for Existing Installations

If you’ve previously installed VS Code, it’s good to verify its status:

rpm -qa | grep code

This command will display any packages with “code” in their name, helping you identify existing installations.

Verify Available Disk Space

Ensure you have sufficient disk space for the installation:

df -h /

Look for the available space in the output. You’ll need at least 500MB free, though more is recommended if you plan to install multiple extensions.

Prepare User Permissions

Make sure your user account has sudo privileges to perform the installation:

groups $(whoami)

Your username should appear in the “wheel” group for proper sudo access.

Method 1: Installing VS Code via Official Microsoft Repository

Installing Visual Studio Code through the official Microsoft repository is the recommended method for most users. This approach ensures you receive automatic updates whenever Microsoft releases new versions.

Importing Microsoft’s GPG Key

First, you need to import Microsoft’s GPG key to verify the authenticity of the packages:

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

This command imports Microsoft’s cryptographic key, ensuring the packages you download and install are genuine and haven’t been tampered with.

Adding the Visual Studio Code Repository

Next, add the Microsoft VS Code repository to your system:

sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'

This command creates a new repository configuration file that tells your package manager where to find VS Code packages.

Updating Package Cache

After adding the repository, update the package cache:

sudo dnf check-update

Installing Visual Studio Code

Now you’re ready to install Visual Studio Code:

sudo dnf install code

The system will download and install VS Code along with any required dependencies. When prompted, type ‘y’ and press Enter to confirm the installation.

Verifying the Installation

After installation completes, verify that VS Code has been installed correctly:

code --version

This command should display the version number of your VS Code installation, confirming that it was installed successfully.

Method 2: Manual Installation Using RPM Package

If you prefer not to add external repositories to your system, you can manually download and install the VS Code RPM package. This method gives you more control over when and how updates are applied.

Downloading the RPM Package

Visit the official Visual Studio Code website and click download the “.rpm” option for Red Hat, Fedora, and SUSE distributions.

Alternatively, you can download the package directly using the terminal:

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

Installing the Downloaded Package

Navigate to the directory where you downloaded the RPM file and install it:

cd ~/Downloads
sudo dnf install ./code.rpm

Replace ~/Downloads with the actual path if you saved the file elsewhere.

Manual Update Process

When using the manual installation method, you’ll need to download and install new versions manually. You can check for updates on the VS Code website or by using the built-in update notifier in VS Code itself.

Troubleshooting Manual Installation

If you encounter dependency issues during installation, you can try:

sudo dnf install --allowerasing ./code.rpm

This command will attempt to resolve dependency conflicts, though use it cautiously as it might remove conflicting packages.

Method 3: Installing VS Code via Snap

Snap packages provide another convenient way to install and manage VS Code on Fedora 42. Snap packages are self-contained and include all necessary dependencies.

Installing Snap Support

First, ensure the Snap daemon is installed:

sudo dnf install snapd

After installation, enable the snap service:

sudo systemctl enable --now snapd.socket

Create a symbolic link to enable classic snap support:

sudo ln -s /var/lib/snapd/snap /snap

Installing VS Code via Snap

Now install VS Code using snap:

sudo snap install --classic code

The --classic flag gives the application more system access, which VS Code requires to function properly.

Managing Snap Permissions

Snap packages run in a sandbox environment with restricted access to your system. You can manage permissions using:

snap connections code

To grant additional permissions:

sudo snap connect code:permission-name

Replace permission-name with the specific permission you want to grant.

Updating VS Code Snap Package

Snap packages update automatically by default. You can manually check for updates:

sudo snap refresh code

Method 4: Installing VS Code via Flatpak

Flatpak offers another sandboxed approach to installing applications on Fedora. Fedora 42 comes with Flatpak pre-installed, making this a convenient option.

Setting Up Flatpak Support

Ensure Flatpak is properly set up with the Flathub repository:

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

If Flathub is not enabled, you can enable it:

flatpak remote-modify --enable flathub

Installing VS Code with Flatpak

Install Visual Studio Code from Flathub:

flatpak install flathub com.visualstudio.code

When prompted, type ‘y’ and press Enter to confirm the installation.

Launching VS Code Installed via Flatpak

To run VS Code installed through Flatpak:

flatpak run com.visualstudio.code

Alternatively, you can find it in your applications menu.

Benefits and Limitations of Flatpak Installation

The Flatpak version of VS Code provides better isolation from your system, which can enhance security. However, this isolation might limit access to some system tools and SDKs. You may need to grant additional permissions for specific development workflows.

Launching and Verifying VS Code

After installing VS Code using any of the above methods, you can launch it in several ways:

Terminal Launch

Open a terminal and run:

code

If you installed VS Code via Flatpak:

flatpak run com.visualstudio.code

Application Menu Launch

  1. Click on Activities in the top-left corner of your screen
  2. Search for “Visual Studio Code” or “VS Code”
  3. Click on the Visual Studio Code icon to launch the application

Install Visual Studio Code on Fedora 42

Verifying the Installation

When VS Code launches for the first time, you’ll see a welcome screen. This confirms your installation was successful.

To check the version information:

  1. Click on Help in the top menu
  2. Select “About”
  3. A dialog will appear showing the version number and build information

Post-Installation Configuration

After installing VS Code, there are several configurations to optimize your development environment:

Essential Preferences

Open Settings (Ctrl+,) to customize VS Code. Some important settings to consider:

  • Editor Font: editor.fontSize and editor.fontFamily
  • Tab Size: editor.tabSize
  • Auto Save: files.autoSave
  • Terminal: terminal.integrated.fontFamily and terminal.integrated.fontSize

Keyboard Shortcuts

VS Code comes with many useful keyboard shortcuts:

  • Open a folder or project: Ctrl+O
  • Create a new file: Ctrl+N
  • Open the integrated terminal: Ctrl+`
  • Open Command Palette: Ctrl+Shift+P
  • Quick file navigation: Ctrl+P

You can customize shortcuts by opening the Command Palette (Ctrl+Shift+P) and searching for “Keyboard Shortcuts.”

Configuring the Integrated Terminal

VS Code includes an integrated terminal that you can customize:

  1. Open Settings (Ctrl+,)
  2. Search for “terminal”
  3. Configure settings like default shell, font size, and color scheme

For example, to use a specific shell like Zsh:

"terminal.integrated.defaultProfile.linux": "zsh"

Setting Up User Interface

VS Code’s interface can be customized with themes:

  1. Open Command Palette (Ctrl+Shift+P)
  2. Type “Preferences: Color Theme”
  3. Select from built-in themes or install additional ones from the marketplace

You can also customize the workbench layout, sidebar position, and panel visibility through the View menu.

Essential VS Code Extensions for Fedora Users

Extensions greatly enhance VS Code’s functionality. Here are some essential extensions for Fedora Linux users:

Language Support Extensions

  • Python: Provides IntelliSense, linting, debugging, and code formatting for Python
  • C/C++: Offers IntelliSense, debugging, and code browsing for C/C++ development
  • JavaScript and TypeScript: Enhanced support for JS/TS development
  • Java Extension Pack: Comprehensive Java development tools

Development Tool Extensions

  • GitLens: Enhanced Git integration with blame annotations and history exploration
  • Docker: Tools for managing Docker containers, images, and workflows
  • Remote – SSH: Edit files on remote machines using SSH
  • Live Share: Real-time collaborative editing and debugging

Linux-Specific Extensions

  • Linux Tools: Helpful utilities specifically for Linux development
  • Bash Debug: Debugging support for Bash scripts
  • ShellCheck: Static analysis for shell scripts
  • VSCode Icons: File icons based on file types, including Linux-specific formats

Installing Extensions

To install extensions:

  1. Click on the Extensions icon in the Activity Bar (or press Ctrl+Shift+X)
  2. Search for the extension you want
  3. Click “Install” next to the extension

Troubleshooting Common VS Code Issues on Fedora 42

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

Repository Access Issues

If you can’t access the Microsoft repository:

ping packages.microsoft.com

If the server doesn’t respond, check your internet connection or try again later.

GPG Key Problems

If you see GPG key errors during installation:

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

Run this command again to reimport the key.

Terminal Not Working

If the integrated terminal doesn’t work:

  1. Try resetting the terminal by selecting Terminal > Reset from the menu
  2. Check terminal settings (Ctrl+,) and search for “terminal”
  3. Verify that your shell executable is correctly configured

Dependency Conflicts

For dependency conflicts during installation:

sudo dnf clean all
sudo dnf update
sudo dnf install code

This sequence clears the package cache, updates all packages, and tries installation again.

File Permission Problems

If VS Code can’t access certain files:

  1. Check if the files are owned by your user:
    ls -l /path/to/your/files
  2. Adjust permissions if necessary:
    chmod u+rw /path/to/your/files

Extensions Not Installing

If extensions fail to install:

  1. Check your internet connection
  2. Try restarting VS Code
  3. Verify VS Code has proper access to your home directory

Keeping VS Code Updated

Keeping VS Code updated ensures you have the latest features, performance improvements, and security fixes.

Repository Method Updates

If you installed VS Code from the Microsoft repository, updates will be included with your system updates:

sudo dnf update

Manual Updates

For manual installations, download the latest RPM and install it:

sudo dnf install ./new-code-version.rpm

Flatpak Updates

Update VS Code installed via Flatpak:

flatpak update com.visualstudio.code

Snap Updates

Snap packages update automatically, but you can manually trigger an update:

sudo snap refresh code

Uninstalling VS Code

If you need to uninstall VS Code, the method depends on how you installed it:

Repository Installation

sudo dnf remove code

To also remove the repository:

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

RPM Package Installation

sudo dnf remove code

Flatpak Installation

flatpak uninstall com.visualstudio.code

Snap Installation

sudo snap remove code

Cleaning Configuration Files

To completely remove VS Code configurations:

rm -rf ~/.config/Code

This removes all user settings, extensions, and configurations.

Congratulations! You have successfully installed Visual Studio Code. Thanks for using this tutorial for installing the Visual Studio Code on Fedora 42 Linux system. For additional help or useful information, we recommend you check the official Visual Studio 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