189

I downloaded the .tar.gz version of VS Code for Ubuntu (64-bit) and have been able to run it smoothly for some time. Some extensions have been installed too.

How can I efficiently update this VS Code installation? One thing I can think of is to just download the new .tar.gz archive and extract to the same location, just keeping the old "extensions" folder.

If I use the .deb version, would the same process be needed? Would I download the new .deb every time there is an update?

8
  • 5
    That's what I've been doing. About once a month I go to the website and download the new version and just install it over the old. Later VS Code has a software update checker built in now in the HELP menu. Cheers, Al
    – heynnema
    Oct 5, 2016 at 23:07
  • 2
    Yes, the installed VS Code has that feature, but whenever there is an update -> it asks with a dialog -> send me to the download site ... It's still somewhat inconvenient.
    – ramcrys
    Oct 13, 2016 at 12:34
  • Well yes... but we are talking about Microsoft, yes? I'm not aware of any PPA or repository for VS Code. Cheers, Al
    – heynnema
    Oct 13, 2016 at 13:57
  • As of v1.10.1 Official signed repositories for Linux have been added. "This enables automatic updates using the platform's update mechanism."
    – DineshKP
    Mar 2, 2017 at 10:23
  • @dinesh kool automatic updates Jul 14, 2017 at 20:37

13 Answers 13

206

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.

5
  • 12
    THis made me have 2 VSCode now installed, I am on Ubuntu
    – cassmtnr
    Jul 12, 2018 at 11:36
  • For me, the old .deb was correctly replaced. @CassianoMontanari did you chose some other form of installation the first time?
    – user18099
    Nov 6, 2018 at 15:27
  • 1
    @user18099 Yes, I installed VSCode via Software Center from Ubuntu. I formatted my PC since then, now on Ubuntu 18.04, installed VSCode only from Software Center.
    – cassmtnr
    Nov 6, 2018 at 17:07
  • 3
    This is not Auto Update. It re-downloads and re-installs every time even if there is no update. And if you have an installed version from apt or snap, you will have a duplicate! Jan 18, 2022 at 23:42
  • 1
    what's confusing here is that if you just double-click on the file in Ubuntu (20.04) it opens with the software installer app which only offers you the "remove" option
    – Andy
    Feb 10, 2022 at 8:29
155

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

12
  • 16
    This is currently the best solution
    – GiorgosK
    Nov 17, 2018 at 7:44
  • 2
    Since there's no such package in the Ubuntu repositories, yes. packages.ubuntu.com/search?keywords=code Read your own link, the steps for adding the repository is just above the steps for installing.
    – muru
    Dec 6, 2018 at 9:15
  • 2
    That's what the question is about, yes, and the repo is added automatically only if you used the deb file to install it in the first place. Not if you used the zip. That's not mentioned in your answer either
    – muru
    Dec 6, 2018 at 14:57
  • 16
    That doe snot seem to work for me. I get code is already the newest version (1.34.0-1557957934), however, the current version is 1.44. Any ideas?
    – Cleb
    Apr 15, 2020 at 18:02
  • 2
    Per VSCode doc as of today October 2021, it can be installed or re-installed via following: sudo apt update and then sudo apt install code Note: apt instead of apt-get Oct 8, 2021 at 10:23
51

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
2
  • 2
    Once it's installed per above, it usually will update whenever you run apt update. That's covered above also. Dec 19, 2019 at 2:04
  • 1
    I made the mistake of downloading the .deb file then just double-clicking it in ubuntu file manager. This launched the sofware update application which showed the new version I had downloaded but didn't give me any option to upgrade; only to remove!
    – Andy
    Feb 16, 2021 at 12:40
13

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.

1
  • This method, just works!
    – Sivadass N
    Apr 11, 2018 at 7:11
5

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

4

Use the script available in this repository: github.com/moeenz/vscode-updater

4

Snap

Visual Studio Code is officially distributed as a Snap package in the Snap Store:

You can install it by running:

sudo snap install --classic code # or code-insiders

Once installed, the Snap daemon will take care of automatically updating VS Code in the background. You will get an in-product update notification whenever a new update is available.

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

1
  • 1
    This got me thinking, why the hack I have old version - and the version I was running was a duplicate from apt install code ... just remove it and use the snap one x)
    – jave.web
    Jan 27, 2022 at 22:37
4

If you get an error message

code is already the newest version (x.xx.x-xxxxx)

The simplest solution is to download the latest binary from the Official Source and then install it by executing the following:

sudo apt install /home/xyz/Downloads/code_x.xx.x-xxxxxxx.deb

This will reinstall code over the older version. Your settings and installed extensions will remain unchanged as expected.

Reference

1
  • It is annoying to do this every month... The wget solution didn't work for me... I think that is the link
    – titusfx
    Aug 11, 2021 at 10:07
3

According to the issue Setup apt repository to enable OS-level updating on Debian-based systems #2973, the official PPA is still in progress.

There are two PPAs hosted on GitHub and openSUSE. You can use https://github.com/tagplus5/vscode-ppa before Visual Studio Code has its official PPA.

1

Follow the steps given below:

  1. Download the latest version of Visual Studio Code as a .deb package.

  2. Install GDebi Package Installer (if not installed).

  3. Then remove Visual Studio Code (older version) by opening its .deb package (which you downloaded earlier) using GDebi Package Installer and then click on "Remove Package" option.

  4. Then open the .deb package of the latest version of Visual Studio Code using GDebi Package Installer and click "Install Package" and install latest version of Visual Studio Code.

All your configurations (packages installed and other customisations) in Visual Studio Code which you did earlier will be restored automatically even after following the above procedure. So you need not worry about installing the packages again. You will find those customisations and packages automatically in the latest version you have installed.

Updating through this procedure doesn't remove/purge configuration files of Visual Studio Code and that's why, all your configurations in Visual Studio Code are restored.

This procedure works also for other code editors, like Sublime Text 3 and Atom. I have myself tested and verified it.

0

The .deb version and the apt version are two different versions for vs code.

The apt version can update by itself while the .deb version cannot.

It seems that the apt version is better, but it might not be the newest version, and for users using languages other than English, some input methods like Sogoupinyin(Chinese) won't work in this version.

The only way I found to update the .deb version is to install it again.

0

Just double-click the downloaded .deb and you are good to go! My system is Ubuntu Mate 22.04 but it's the same.

PS: The only side effect is that I lost the icons of the program - replaced by a not-found image!

-1

Get the .deb file from https://code.visualstudio.com and run it from system package manager. Here's the official source link.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .