How to install vs code on ubuntu
How to install vs code on ubuntu
Как установить Visual Studio Code на Ubuntu
В этой статье мы рассмотрим, как установить Visual Studio Code на Ubuntu 18.04 или более поздних версий. Для этого лучше всего использовать официальный репозиторий от Microsoft. Однако можно также воспользоваться snap-пакетом или центром приложений Ubuntu.
Установка Visual Studio Code на Ubuntu
Для работы репозитория нужно установить несколько пакетов. Для этого выполните команду:
sudo apt install software-properties-common apt-transport-https wget
Затем установите ключ репозитория:
И добавьте сам репозиторий:
sudo add-apt-repository «deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main»
После этого остается обновить списки пакетов и установить VS Code:
sudo apt update
sudo apt install code
После завершения установки вы можете запустить программу, выполнив в терминале команду code, или через главное меню системы:
Главное окно программы будет выглядеть вот так:
Также можно установить программу с помощью менеджера пакетов snap. Для этого выполните:
А ещё программа есть в центре приложений Ubuntu:
Удаление Visual Studio Code в Ubuntu
Удалять программу надо так, как вы её устанавливали. Если установка Visual Studio Code Ubuntu 18.04 выполнялась из репозитория Microsoft, то для удаления выполните:
sudo apt purge code
Затем можно отключить репозиторий с помощью утилиты Программы и обновления:
А если установка выполнялась через менеджер пакетов snap или центр приложений, то для удаления достаточно выполнить:
sudo snap remove code
Выводы
Теперь у вас есть успешно установленная VS Code Ubuntu 18.04, и вы можете переходить к её настройке, а затем к программированию. Далее вам нужно настроить внешний вид среды, а также установить необходимые дополнения. Но об этом поговорим в следующих статьях.
How to Install Visual Studio Code On Ubuntu 20.04
Visual Studio Code is a streamlined Code Editor that comes up with various operations such as debugging, syntax highlighting, version control, code completion.
You can insert, expand, generate, and collapse different code blocks using the editor’s various properties, such as outlining and code snippets.
Many folks confused Visual Studio with Visual Studio Code. Visual Studio is exclusively available on Windows for windows application development, while Visual Studio Code is a simple code editor available for many platforms.
Now we will check a couple of ways to get Visual Studio Code on Ubuntu 20.04. Pick the most appropriate one according to your convenience.
1- Install Visual Studio Code On Ubuntu 20.04 (LTS) and 20.10 Using GUI:
To install Visual Studio Code through GUI, Firstly, open Software Center on Ubuntu.
You will get a Software Center window.
Now, search “Visual Studio Code”:
Select “Visual Studio Code”, a window will appear with Install Button; click on it to start the process.
2- Install Visual Studio Code On Ubuntu 20.04 (LTS) and 20.10 Using Terminal:
In this method, we will download and install Visual Studio Code using snap. Snap packages include binary dependencies which are secure and easy to upgrade.
To start the process, open your terminal and type the command given below:
Another way of installing VS code is using the terminal via the “apt” command.
There are few steps to follow:
Step 1: First, we need to install dependencies using the below-mentioned command.
Step 2: Next step is to import the given Microsoft GPG key on the terminal through the wget command:
Step 3: Moving forward, type the following command to enable VS code repository:
As you can see, the repository is added. Now, the last step for this process is to type installation command of Visual Studio Code package, which is mentioned below:
Visual Studio Code will be downloaded and installed on your device. It can be viewed in applications. Open it:
How to uninstall Visual Studio Code on Ubuntu 20.04 (LTS) and 20.10:
If you’ve installed it from GUI, then to remove it, follow the steps listed below:
If you have installed Visual Studio Code through the terminal by snap packages.
Use command to uninstall it:
Conclusion
You’ve seen a brief introduction about how to install Visual Studio Code using a couple of ways that are via GUI and Terminal. We have also learned how to uninstall it in various ways. Visual Studio Code is a fast, reliable, and efficient code editor that supports various programming languages and tons of plugins to enhance productivity.
About the author
Wardah Batool
I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.
Visual Studio Code on Linux
Installation
See the Download Visual Studio Code page for a complete list of available installation options.
By downloading and using Visual Studio Code, you agree to the license terms and privacy statement.
Debian and Ubuntu based distributions
Note that other binaries are also available on the VS Code download page.
Then update the package cache and install the package using:
RHEL, Fedora, and CentOS based distributions
We currently ship the stable 64-bit VS Code in a yum repository, the following script will install the key and repository:
Then update the package cache and install the package using dnf (Fedora 22 and above):
Or on older versions using yum :
Due to the manual signing process and the system we use to publish, the yum repo may lag behind and not get the latest version of VS Code immediately.
Visual Studio Code is officially distributed as a Snap package in the Snap Store:
You can install it by running:
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.
Note: If snap isn’t available in your Linux distribution, please check the following Installing snapd guide, which can help you get that set up.
Learn more about snaps from the official Snap Documentation.
openSUSE and SLE-based distributions
The yum repository above also works for openSUSE and SLE-based systems, the following script will install the key and repository:
Then update the package cache and install the package using:
AUR package for Arch Linux
To get more information about the installation from the AUR, please consult the following wiki entry: Install AUR Packages.
Nix package for NixOS (or any Linux distribution using Nix package manager)
There is a community maintained VS Code Nix package in the nixpkgs repository. In order to install it using Nix, set allowUnfree option to true in your config.nix and execute:
Note that other binaries are also available on the VS Code download page.
Updates
VS Code ships monthly and you can see when a new release is available by checking the release notes. If the VS Code repository was installed correctly, then your system package manager should handle auto-updating in the same way as other packages on the system.
Note: Updates are automatic and run in the background for the Snap package.
Node.js
Node.js is a popular platform and runtime for easily building and running JavaScript applications. It also includes npm, a Package Manager for Node.js modules. You’ll see Node.js and npm mentioned frequently in our documentation and some optional VS Code tooling requires Node.js (for example, the VS Code extension generator).
If you’d like to install Node.js on Linux, see Installing Node.js via package manager to find the Node.js package and installation instructions tailored to your Linux distribution. You can also install and support multiple versions of Node.js by using the Node Version Manager.
To learn more about JavaScript and Node.js, see our Node.js tutorial, where you’ll learn about running and debugging Node.js applications with VS Code.
Setting VS Code as the default text editor
xdg-open
You can set the default text editor for text files ( text/plain ) that is used by xdg-open with the following command:
Debian alternatives system
Debian-based distributions allow setting a default editor using the Debian alternatives system, without concern for the MIME type. You can set this by running the following and selecting code:
Windows as a Linux developer machine
Another option for Linux development with VS Code is to use a Windows machine with the Windows Subsystem for Linux (WSL).
Windows Subsystem for Linux
With WSL, you can install and run Linux distributions on Windows. This enables you to develop and test your source code on Linux while still working locally on a Windows machine. WSL supports Linux distributions such as Ubuntu, Debian, SUSE, and Alpine available from the Microsoft Store.
See the Developing in WSL documentation to learn more or try the Working in WSL introductory tutorial.
Next steps
Once you have installed VS Code, these topics will help you learn more about it:
Common questions
Azure VM Issues
I’m getting a «Running without the SUID sandbox» error?
You can safely ignore this error.
Debian and moving files to trash
If you see an error when deleting files from the VS Code Explorer on the Debian operating system, it might be because the trash implementation that VS Code is using is not there.
Run these commands to solve this issue:
Conflicts with VS Code packages from other repositories
Some distributions, for example Pop!_OS provide their own code package. To ensure the official VS Code repository is used, create a file named /etc/apt/preferences.d/code with the following content:
«Visual Studio Code is unable to watch for file changes in this large workspace» (error ENOSPC)
The limit can be increased to its maximum by editing /etc/sysctl.conf (except on Arch Linux, read below) and adding this line to the end of the file:
While 524,288 is the maximum number of files that can be watched, if you’re in an environment that is particularly memory constrained, you may want to lower the number. Each file watch takes up 1080 bytes, so assuming that all 524,288 watches are consumed, that results in an upper bound of around 540 MiB.
Arch-based distros (including Manjaro) require you to change a different file; follow these steps instead.
I can’t see Chinese characters in Ubuntu
Package git is not installed
This error can appear during installation and is typically caused by the package manager’s lists being out of date. Try updating them and installing again:
The code bin command does not bring the window to the foreground on Ubuntu
Under General > General Options > Focus & Raise Behaviour, set «Focus Prevention Level» to «Off». Remember this is an OS-level setting that will apply to all applications, not just VS Code.
This can happen when sources.list.d doesn’t exist or you don’t have access to create the file. To fix this, try manually creating the folder and an empty vscode.list file:
Cannot move or resize the window while X forwarding a remote window
Using the custom title bar
The custom title bar and menus were enabled by default on Linux for several months. The custom title bar has been a success on Windows, but the customer response on Linux suggests otherwise. Based on feedback, we have decided to make this setting opt-in on Linux and leave the native title bar as the default.
The custom title bar provides many benefits including great theming support and better accessibility through keyboard navigation and screen readers. Unfortunately, these benefits do not translate as well to the Linux platform. Linux has a variety of desktop environments and window managers that can make the VS Code theming look foreign to users. For users needing the accessibility improvements, we recommend enabling the custom title bar when running in accessibility mode using a screen reader. You can still manually set the title bar with the Window: Title Bar Style ( window.titleBarStyle ) setting.
Broken cursor in editor with display scaling enabled
Repository changed its origin value
If you receive an error similar to the following:
Use apt instead of apt-get and you will be prompted to accept the origin change:
How to install vs code on ubuntu
Visual Studio Code on Linux
See the Download Visual Studio Code page for a complete list of available installation options.
By downloading and using Visual Studio Code, you agree to the license terms and privacy statement.
Debian and Ubuntu based distributions
Note that other binaries are also available on the VS Code download page.
Then update the package cache and install the package using:
RHEL, Fedora, and CentOS based distributions
We currently ship the stable 64-bit VS Code in a yum repository, the following script will install the key and repository:
Then update the package cache and install the package using dnf (Fedora 22 and above):
Or on older versions using yum :
Due to the manual signing process and the system we use to publish, the yum repo may lag behind and not get the latest version of VS Code immediately.
Visual Studio Code is officially distributed as a Snap package in the Snap Store:
You can install it by running:
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.
Note: If snap isn’t available in your Linux distribution, please check the following Installing snapd guide, which can help you get that set up.
Learn more about snaps from the official Snap Documentation.
openSUSE and SLE-based distributions
The yum repository above also works for openSUSE and SLE-based systems, the following script will install the key and repository:
Then update the package cache and install the package using:
AUR package for Arch Linux
To get more information about the installation from the AUR, please consult the following wiki entry: Install AUR Packages.
Nix package for NixOS (or any Linux distribution using Nix package manager)
There is a community maintained VS Code Nix package in the nixpkgs repository. In order to install it using Nix, set allowUnfree option to true in your config.nix and execute:
Note that other binaries are also available on the VS Code download page.
VS Code ships monthly and you can see when a new release is available by checking the release notes. If the VS Code repository was installed correctly, then your system package manager should handle auto-updating in the same way as other packages on the system.
Note: Updates are automatic and run in the background for the Snap package.
Node.js is a popular platform and runtime for easily building and running JavaScript applications. It also includes npm, a Package Manager for Node.js modules. You’ll see Node.js and npm mentioned frequently in our documentation and some optional VS Code tooling requires Node.js (for example, the VS Code extension generator).
If you’d like to install Node.js on Linux, see Installing Node.js via package manager to find the Node.js package and installation instructions tailored to your Linux distribution. You can also install and support multiple versions of Node.js by using the Node Version Manager.
To learn more about JavaScript and Node.js, see our Node.js tutorial, where you’ll learn about running and debugging Node.js applications with VS Code.
Setting VS Code as the default text editor
You can set the default text editor for text files ( text/plain ) that is used by xdg-open with the following command:
Debian alternatives system
Debian-based distributions allow setting a default editor using the Debian alternatives system, without concern for the MIME type. You can set this by running the following and selecting code:
Windows as a Linux developer machine
Another option for Linux development with VS Code is to use a Windows machine with the Windows Subsystem for Linux (WSL).
Windows Subsystem for Linux
With WSL, you can install and run Linux distributions on Windows. This enables you to develop and test your source code on Linux while still working locally on a Windows machine. WSL supports Linux distributions such as Ubuntu, Debian, SUSE, and Alpine available from the Microsoft Store.
See the Developing in WSL documentation to learn more or try the Working in WSL introductory tutorial.
Once you have installed VS Code, these topics will help you learn more about it:
Azure VM Issues
I’m getting a «Running without the SUID sandbox» error?
You can safely ignore this error.
Debian and moving files to trash
If you see an error when deleting files from the VS Code Explorer on the Debian operating system, it might be because the trash implementation that VS Code is using is not there.
Run these commands to solve this issue:
Conflicts with VS Code packages from other repositories
Some distributions, for example Pop!_OS provide their own code package. To ensure the official VS Code repository is used, create a file named /etc/apt/preferences.d/code with the following content:
«Visual Studio Code is unable to watch for file changes in this large workspace» (error ENOSPC)
The limit can be increased to its maximum by editing /etc/sysctl.conf (except on Arch Linux, read below) and adding this line to the end of the file:
While 524,288 is the maximum number of files that can be watched, if you’re in an environment that is particularly memory constrained, you may want to lower the number. Each file watch takes up 1080 bytes, so assuming that all 524,288 watches are consumed, that results in an upper bound of around 540 MiB.
Arch-based distros (including Manjaro) require you to change a different file; follow these steps instead.
I can’t see Chinese characters in Ubuntu
Package git is not installed
This error can appear during installation and is typically caused by the package manager’s lists being out of date. Try updating them and installing again:
The code bin command does not bring the window to the foreground on Ubuntu
Under General > General Options > Focus & Raise Behaviour, set «Focus Prevention Level» to «Off». Remember this is an OS-level setting that will apply to all applications, not just VS Code.
This can happen when sources.list.d doesn’t exist or you don’t have access to create the file. To fix this, try manually creating the folder and an empty vscode.list file:
Cannot move or resize the window while X forwarding a remote window
Using the custom title bar
The custom title bar and menus were enabled by default on Linux for several months. The custom title bar has been a success on Windows, but the customer response on Linux suggests otherwise. Based on feedback, we have decided to make this setting opt-in on Linux and leave the native title bar as the default.
The custom title bar provides many benefits including great theming support and better accessibility through keyboard navigation and screen readers. Unfortunately, these benefits do not translate as well to the Linux platform. Linux has a variety of desktop environments and window managers that can make the VS Code theming look foreign to users. For users needing the accessibility improvements, we recommend enabling the custom title bar when running in accessibility mode using a screen reader. You can still manually set the title bar with the Window: Title Bar Style ( window.titleBarStyle ) setting.
Broken cursor in editor with display scaling enabled
Repository changed its origin value
If you receive an error similar to the following:
Use apt instead of apt-get and you will be prompted to accept the origin change:
How to Install Visual Studio Code on Ubuntu 20.04 & Above
Microsoft’s Visual Studio Code is a powerful and popular open source code editor. In this post I show you how to install VSCode on Ubuntu 20.04 LTS (or above).
Visual Studio Code is available for Windows, macOS, and Linux. The cross-platform support is a big part of this editor’s appeal, as it means developers don’t need to switch tools or learn new UIs when switching between platforms.
Virtually all of VSCode features are available to all users, regardless of the OS they use it on. Features like debugging, syntax highlighting, intelligent auto completion, embedded Git control, and even an integrated terminal, are enabled in all builds.
Whatever way you choose to install it is up you as you still get the same version of the app, with all of the same features.
Install Visual Studio Code (Snap Package)
Microsoft provide an official Visual Studio Code Snap package on Canonical’s Snapcraft Store.
What are Snaps? They are self-contained software packages that include the binary all dependencies needed to run the application. Snap packages are easy to upgrade and secure. You can install Snap packages using the Ubuntu Software application, or by diving into the command line.
To install the VS Code snap you can click this button:
Or open the Ubuntu Software app and search for “Visual Studio Code” by name.
Alternatively, if you’re more comfortable at the command line, pop open your preferred terminal emulator ( Ctrl + Alt + T ) and run this command:
That’s all you need to do to get Visual Studio Code installed on your system.
What about future updates? No worries there either, as new versions of Visual Studio Code are automatically downloaded and installed in the background, as you use your computer.
Install Visual Studio Code (deb Package)
Microsoft maintain an apt repository for Linux users to install Visual Studio Code from.
You can add the Visual Studio Code apt repository by hand using the command line. But a quicker way to get it set-up on your system is to download and install the VSCode Linux package from the application’s website. As part of the install process the apt repository gets added to your list of Software Sources.
When a new version is released you can update the Visual Studio Code package (alongside any other updates you have) using Ubuntu’s Software Updater tool.
Bonus: Install Visual Studio Code (Flatpak)
If you have Flatpak (and more important Flathub) set-up on your system you can install the VSCode Flatpak package from Flathub.
Ubuntu does not support Flatpak out-of-the-box (we have a guide showing how to install Flatpak on Ubuntu) and for GUI installation you will need to install the gnome-software package as well.
This Visual Studio Code Flatpak is not maintained by Microsoft.
Using Visual Studio Code
To open VSCode on Ubuntu just click the ‘Applications’ icon at the base of the Ubuntu Dock (or hit the super key). In the search bar start to type “Visual Studio Cord” and, when the app icon appears, click on the icon to ope the application.
You’re then free to install VSCode extensions, customise the UI, and playing around with the broad feature set provided. To enable the ‘dual pane’ mode in our screenshot click the “[|]” icon near the tab bar.
Conclusion
There you have it; you know how to install VS Code on Ubuntu 20.04 LTS. This guide also works for many of Ubuntu’s official flavours, as well as spins and other derivatives, including Linux Mint.
For more detail about VS Code I recommend visiting the documentation site Microsoft has created. It is crammed to the hilt with tips and ideas on getting the most out of the editor. You may want to check out VSCode on GitHub too, which is where you can file bug reports.
Home » How To » How to Install Visual Studio Code on Ubuntu 20.04 & Above