141

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?

6
  • 4
    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 '16 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 '16 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 '16 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."
    – Dinesh
    Mar 2 '17 at 10:23
  • @dinesh kool automatic updates Jul 14 '17 at 20:37

11 Answers 11

157

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.

3
  • 6
    THis made me have 2 VSCode now installed, I am on Ubuntu Jul 12 '18 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 '18 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. Nov 6 '18 at 17:07
98

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

10
  • 12
    This is currently the best solution
    – GiorgosK
    Nov 17 '18 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 '18 at 9:15
  • 1
    I don't see that. The question isn't about installing, but about updating. Dec 6 '18 at 10:46
  • 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 '18 at 14:57
  • 5
    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 '20 at 18:02
37

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
3
  • 2
    But the question is about updating, not just installing. Dec 18 '19 at 20:35
  • 2
    Once it's installed per above, it usually will update whenever you run apt update. That's covered above also.
    – Don Cullen
    Dec 19 '19 at 2:04
  • 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 at 12:40
7

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 '18 at 7:11
4

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

3

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

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.

2

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

2

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 at 10:07
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.

-1

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.