How to Update Visual Studio Code in Ubuntu Using Terminal

Introduction

Visual Studio Code (VSCode) is a popular and versatile code editor known for its vast library of extensions, extensive customization options, and cross-platform compatibility. Keeping VSCode up-to-date on your Ubuntu system is crucial for accessing the latest features, bug fixes, and security enhancements. This article will guide you through the simple process of updating VSCode in Ubuntu using the command line, providing step-by-step instructions and troubleshooting tips to ensure a seamless update experience.

How to Install Visual Studio Code on Ubuntu 22.04 – TecAdmin
Image: tecadmin.net

Updating VSCode Using Terminal

  1. Open a Terminal Window: Launch a terminal window by pressing “Ctrl + Alt + T” or searching for “Terminal” in the Applications menu.

  2. Update the System: Before updating VSCode, it’s advisable to update your Ubuntu system to ensure all dependencies are up-to-date. Run the following command in the terminal:

    sudo apt update
  3. Add the Microsoft Repository: To ensure access to the official VSCode repository, add the Microsoft repository to your system:

    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BC11871B4FAB6144
  4. Create a List File for VSCode: Create a file in the “/etc/apt/sources.list.d/” directory to add the VSCode repository:

    echo 'deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main' | sudo tee /etc/apt/sources.list.d/vscode.list
  5. Refresh the Package List: Update the package list to include the newly added repository:

    sudo apt update
  6. Install or Update VSCode: Once the package list is updated, you can install or update VSCode using the following command:

    sudo apt install code # For installation
    sudo apt update && sudo apt upgrade code # For updates
  7. Confirm Installation: Verify the successful installation or update of VSCode by checking the version:

    code --version

Troubleshooting

  1. Permission Denied: If you encounter a “Permission Denied” error while adding the Microsoft repository, ensure you have administrative privileges by running the commands as “sudo”.

  2. Unrecognized Key: If the key added for the Microsoft repository is not recognized, try importing it manually using the following command:

    wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
  3. Package Not Found: If VSCode is not found after installation, check if the correct version of the repository was added. You can also manually download and install the VSCode package from the Microsoft website.

  4. Extension Updates: After updating VSCode, check if your extensions are up-to-date. Outdated extensions can cause compatibility issues.

How to Install Visual Studio Code On Ubuntu 20.04
Image: linuxhint.com

How To Update Visual Studio Code In Ubuntu Using Terminal

Conclusion

Updating Visual Studio Code in Ubuntu is a simple task that can be accomplished through the terminal with minimal effort. By following the steps outlined in this article, you can ensure that your VSCode installation is always current, providing you with access to the latest features and enhancements. Remember to check for updates regularly to stay ahead of bugs and security vulnerabilities, maintaining a smooth and efficient coding experience.