How can I update Visual Studio Code on Ubuntu?

Solution 1:

The following commands work for me:

wget 'https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64' -O /tmp/code_latest_amd64.deb
sudo dpkg -i /tmp/code_latest_amd64.deb

Place those two commands into an executable Bash script called auto-update-vscode, and you can simply run that from your shell any time Visual Studio Code says it's out of date.

Solution 2:

Updated answer October 2021:

If you installed the software using the .deb file you don't have to download the package manually. You can just do:

sudo apt update 
sudo apt install code

Thanks to @MuhammadSheraz


Old answer:

sudo apt-get update
sudo apt-get install code 

source: https://code.visualstudio.com/docs/setup/linux

Solution 3:

Vladimir S. posted the correct solution, although he originally didn't link directly to the section that had the answer. The direct link is here.

For those who'd rather not click, here's the official solution per Microsoft:

Debian and Ubuntu based distributions

The easiest way to install for Debian/Ubuntu based distributions is to download and install the .deb package (64-bit) either through the graphical software center if it's available or through the command line with:

sudo dpkg -i <file>.deb
sudo apt-get install -f # Install dependencies

Installing the .deb package will automatically install the apt repository and signing key to enable auto-updating using the regular system update mechanism (apt update). Note that 32-bit and .tar.gz binaries are also available on the download page.

The repository and key can also be installed manually with the following script:

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] http://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'

Then update the package cache and install the package using:

sudo apt-get update
sudo apt-get install code # or code-insiders

Solution 4:

In true Microsoft style, they decided to call the package just code. So download the latest .deb and:

sudo dpkg -r code
sudo dpkg -i code_downloaded_package.deb

Configuration files, installed extensions and even currently used folder are preserved.

Solution 5:

Since version 1.10.2, Visual Studio Code has got the official signed repositories for Linux. Please look here.