'How to upgrade Visual Studio Code editor?

What's the best way to upgrade Visual Studio Code on Linux Ubuntu?

For the time being I was periodically getting the newest version (.deb) from their official site: https://code.visualstudio.com/

sudo dpkg -i code_*.deb


Solution 1:[1]

Visual Studio Code enabled official Linux repositories on February 2017 (v1.10)

sudo add-apt-repository -y "deb https://packages.microsoft.com/repos/vscode stable main "
sudo apt update
sudo apt -y install code

You can upgrade / dist-upgrade as usual

sudo apt -y upgrade
sudo apt -y dist-upgrade

Solution 2:[2]

[1]: download the latest vscode (.deb) package to your computer on this link :

https://go.microsoft.com/fwlink/?LinkID=760868

, or this there :
https://code.visualstudio.com/docs/

[2]: then open a terminal in the folder where you downloaded the .deb file and write:

sudo dpkg -i <the downloaded file>.deb

[3]: finally if you have apt-get do (if not install apt-get first):

sudo apt-get install -f

Solution 3:[3]

If you have installed it via the repository, exit VS Code then just do:

sudo apt update
sudo apt install code

This is the same command to install or upgrade to the latest version. You can see the version with:

code --version

Now the easiest and recommended way is to use snap:

sudo snap install --classic code

And updates are supposed to be automatic.

Solution 4:[4]

This works fine in ubuntu.

sudo apt-get update
sudo apt-get install code 

Solution 5:[5]

  1. When you install VSCode with the file .deb on Ubuntu 20.08, first, remove it:

    sudo apt-get remove code
    
  2. Add the repository in this link https://code.visualstudio.com/docs/setup/linux

     wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
     sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
     sudo sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
    
  3. Udate the package cache and reinstall

     sudo apt-get install apt-transport-https
     sudo apt-get update
     sudo apt-get install code 
    
  4. In the next time when you want to upgrade, just do:

     sudo apt-get update
     sudo apt-get upgrade code
    

Because your repository is missing information to upgrade VSCode, the above solution will fix it.

Solution 6:[6]

I'm running Ubuntu 20.04 and this worked perfectly for me:

    $ wget https://vscode-update.azurewebsites.net/latest/linux-deb-x64/stable -O /tmp/code_latest_amd64.deb

    $ sudo dpkg -i /tmp/code_latest_amd64.deb

Solution 7:[7]

This is what I did to avoid the annoying message:

  1. Remove vscode, if you already installed it.
sudo apt-get remove code
  1. Add repositories, update and install:
sudo add-apt-repository -y "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main "
sudo apt update
sudo apt -y install code

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 zurfyx
Solution 2 marcdahan
Solution 3
Solution 4 Mahadev Gouda
Solution 5 fcdt
Solution 6 R. S
Solution 7 ericson