Raspberry Pi Visual Studio Code: Installing VS Code on Raspbian

In this Raspberry Pi Visual Studio Code (VS Code) tutorial I go through all the steps to installing this handy code editor.

Raspberry Pi Visual Studio Code

If you’re using the Raspberry Pi as a desktop and want a decent program to edit and create code, then Visual Studio Code is perfect. It is feature packed and contains basically everything you will need to make your very own programs.

I recommend using a Git service such a self-hosted Git, GitHub or even Gitlab. These software packages are not just great for version control but also making sure that your code is backed up and readily available.

There are many other code editors that you can use on the Raspberry Pi. Each of the editors has their own pros and cons. I find VS Code one of the best that you can easily install on the Raspberry Pi.

Note: Due to changes in Visual Studio Code, you can only install version 1.29 (Outdated). We will update this tutorial as soon as it is possible to install newer versions of VSC.

Equipment

Below are all the pieces of equipment that I made use of to do this Raspberry Pi VS Code tutorial.

Recommended:

 Raspberry Pi 2 or 3

 Micro SD Card

Power Adapter

 Ethernet Cord (Recommended) or WiFi dongle

Optional:

 Raspberry Pi Case

Main Features of Visual Studio Code

Many features of Visual Studio Code makes it stand out from alternatives. One of the best parts is that it’s completely free and very customizable.

Open Source & Free

An exciting part of VS Code is that it is completely open source and you can view all the code on GitHub. It is registered under the MIT license allowing you flexibility if you wanted to fork and edit the code.

You can also check the Raspberry Pi build on GitHub. These two Github’s are important if you wanted to check out what you’re about to install.

Visual Studio Code GitHub

Built-in Git

This feature is super handy if you use version control a lot. It works with Git and other SCM (Software Configuration Management) providers and allows you to review diffs, stages and commit files from within the editor.

Visual Studio Code Built-in Git

Debugging Capabilities

You can debug your code in the editor which helps reduce the amount you need to rely on print statement debugging. You can debug your apps using breakpoints, call stacks and an interactive console.

Visual Studio Code Inbuilt Debugging

Extensible and Customizable

One of the coolest features of Visual Studio Code is how extensible. For example, you can install new language packs, themes, debuggers, formatting tools, and so much more.

All your extensions are in separate processes so that they won’t slow down the editor.

Visual Studio Code Extensible and Customizable

Installing Visual Studio Code

Jay or aka Headmelted provides builds of Visual Studio Code that can work on the less popular platforms. This range includes operating systems such as ChromeOS, Raspbian, Linux Mint, Fedora and more.

The apt.sh script further down the page will typically add the required GPG keys for the package to install correctly. However, I have had issues with it working correctly. To install the correct GPG keys simply run the following command.

wget https://packagecloud.io/headmelted/codebuilds/gpgkey -O - | sudo apt-key add -

To install Visual Studio Code, you only need to run a straightforward command.

curl -L https://raw.githubusercontent.com/headmelted/codebuilds/master/docs/installers/apt.sh | sudo bash

Once done you should be able to find the visual studio code under the accessories menu called Code-OSS.

Visual Studio Code Menu Location

You can now start coding to hearts desire on the Raspberry Pi. You should realize quickly why Visual Studio Code has become a favorite amongst many avid programmers.

I hope that this Raspberry Pi Visual Studio Code tutorial has shown you all the steps to setting up this code editor. If you have some thoughts, tips or anything else then please feel free to leave a comment below.

13 Comments

  1. renzo on

    for some reason, the 2nd step isn’t working for me.
    curl -L https://code.headmelted.com/installers/apt.sh | sudo bash

    the error I get is “Ocurl: (6) could not resolve host: code.headmelted.com

    1. Emmet on

      Hi Renzo,

      It appears as if that code.headmelted.com is currently having DNS routing issues.

      We have updated the tutorial to point to the file directly from the github repository.

      Try running the following command instead
      curl -L https://raw.githubusercontent.com/headmelted/codebuilds/master/docs/installers/apt.sh | sudo bash

      Cheers,

      Emmet

  2. Andi Kunar on

    Just FYI – The latest (as of Summer 2019) insider-version of Visual Studio Code supports remotely connecting to a Raspberry Pi via plain SSH (and I also run it on Tinker Boards). This means your dev environment runs on your standard host (PC/Mac/…) while your files as well as execution environment are on the Pi. This is a bit of an early code but to me it looks very interesting.

  3. Ashish on

    It is very good I have download vs code & I loved it.

  4. Wayne on

    This worked great! The fix provided above for the blank screen was required in my case as well.

  5. swiic on

    If you use ssh, you can connect your VS Code with the SFTP plugin.

    Better than coding on the pi 🙂

    1. arsdever on

      But how to do that? I try to run it via ssh and enable the server, then connect to the server from my laptop, but it seems to be impossible. When I run it, it simply stops after a second

  6. Hard on

    I am getting blank screen on Rasoberry Pi 3B+ after installing code-oss. Can you please help?

    1. Gus on

      Hi,

      Please see the comment above for a fix regarding the blank screen for code-oss.

  7. Ulu on

    Hi,

    thanks a lot for this tutorial!
    I can install code-oss fine, but I cannot get it to start properly, it is just showing me an empty black screen.
    This behaviour happens when opening from the menu, opening from the terminal or by opening a (very simple) script.

    Would you have any tip about this?

    Thanks

    1. Gus on

      Hi Ulu,

      A recent update seems to have made this happen.

      You can downgrade VS code by running the following command.

      sudo apt-get install code-oss=1.29.0-1539702286

      Mark it “on hold” so it doesn’t upgrade to the latest version automatically.

      sudo apt-mark hold code-oss

      To remove the hold, just enter the following.

      sudo apt-mark unhold code-oss

      Multiple Github issues have been opened regarding this issue, so hopefully it will be fixed soon.

  8. bonzadog on

    This looks interesting, I will try it out asap.

  9. Cesar Mello on

    Wonderful, worked perfectly!!! It will help a lot my 9-year-old daughter learn coding. Thank you very very much!!!

Leave a Reply

Your email address will not be published. Required fields are marked *