Visual Studio Code For Raspberry Pi

Sponsored By
  1. Visual Studio On Raspberry Pi
  2. Visual Studio Code For Raspberry Pi 4
  3. Install Visual Studio Code Raspberry Pi
  4. Visual Studio Code For Raspberry Pi

When you click “Remote GDB Debugger” Visual Studio performs the compilation and execution processes. Visual Studio creates the following files on the remote device (in this case, my Raspberry Pi). Project = Blink, code = main.c. Raspberry Pi Officially Embraces Visual Studio Code, Telemetry and All. The Raspberry Pi Foundation has officially embraced Microsoft's open source Visual Studio Code editor, known for its cross-platform capabilities enhanced by a vast selection of extensions. Fans of both Raspberry Pi and Visual Studio Code (aka VS Code) are rejoicing – in February 2021, it was announced that the two tech products will now be integrated! For those who don’t yet know, VS Code is an open-source code editor that was first developed for Windows, Mac, and Linux.

There's been a lot of folks, myself included, who have tried to install VS Code on the Raspberry Pi. In fact, there's a lovely process for this now. However, we have to ask ourselves is a Raspberry Pi really powerful enough to be running a full development environment and the app being debugged? Perhaps, but maybe this is a job for remote debugging. That means installing Visual Studio Code locally on my Windows or Mac machine, then having Visual Studio code install its headless server component (for ARM7) on the Pi.

In January I blogged about Remote Debugging with VS Code on a Raspberry Pi using .NET Core on ARM. It was, and is, a little hacked together with SSH and wishes. Let's set up a proper VS Code Remote environment so I can be productive on a Pi while still enjoying my main laptop's abilities.

Visual Studio Code is officially distributed via the Raspberry Pi OS (previously called Raspbian) APT repository, in both 32-bit and 64-bit variants. You can install it by running: sudo apt update sudo apt install code Running VS Code. After installing the VS Code package, you can run VS Code by typing code in a terminal or launching it via the Programming menu. A Visual Studio Extension for debugging.NET Core applications remotely on a Raspberry Pi IMPORTANT:.NET 5.0 starting with the SDK 5.0.102 works now! You can use Visual Studio Code to develop and debug.NET Core applications either directly on your Raspberry or remotely from another computer but until today, there's been no easy way to use.

  • First, can you ssh into your Raspberry Pi without a password prompt?
    • If not, be sure to set that up with OpenSSH, which is now installed on Windows 10 by default.
    • You know you've got it down when you can 'ssh [email protected]' and it just drops you into a remote prompt.
  • Next, get Visual Studio Code Insiders plus
    • Remote Development Extension
      • Uninstall the 'Remote - SSH' Extensions, disabling them isn't enough because you want to replace them with..
    • Important - Remote - SSHNightly Builds

From within VS Code Insiders, hit Ctrl/CMD+P and type 'Remote-SSH' for some of the choices.

I can connect to Host and VS Code will SSH into the PI and install the VS Code server components in ~./vscode-server-insiders and then connect to them. It will take a minute as its downloading a 25 meg GZip and unzipping it into this temp folder. You'll know you're connected when you see this green badge as seen below that says 'SSH: hostname.'

Then when you go 'File Open Folder' from the main menu, you'll get the remote system's files! You are working and editing locally on remote files.

Note here that some of the extensions are NOT installed locally! The Python language services (using Jedi) are running remotely on the Raspberry Pi, so when I get intellisense, I'm getting it remoted from the actual machine I'm developing on, not a guess from my local box.

When I open a Terminal with Ctrl+~, see that I'm automatically getting a remote terminal and I've even running htop in it!

Check this out, I'm doing a remote interactive debugging session against CrowPi samples running on the Raspberry Pi (in Python 2) remotely from VS Code on my Windows 10 machine! I did need to make one change to the remote settings as it was defaulting to Python3 and I wanted to use Python2 for these samples.

This has been a very smooth process and I remain super impressed with the VS Remote Development experience. I'll be looking at containers, and remote WSL debugging soon as well. Next step is to try C#, remotely, which will mean making sure the C# OmniSharp Extension works on ARM and remotely.

Sponsor: Suffering from a lack of clarity around software bugs? Give your customers the experience they deserve and expect with error monitoring from Installs in minutes, try it today!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.


This article is part of a series.

  • Part 1 - Installing Arch Linux on Raspberry Pi with Immediate WiFi Access
  • Part 2 - Setup i2c on Raspberry Pi Zero W using Arch Linux
  • Part 3 - Setup NodeJS Project Space on Raspberry Pi Zero W
  • Part 4 - Porting DRV8830 I2C Motor Driver Code to NodeJS
  • Part 5 - This Article
  • Part 6 - 1B1 Robot
  • Part 7 - Google Vision API using Raspberry Pi and Node

I’m spoiled. I love the pretty colors of modern text IDEs. My favorite among them being Visual Studio Code.

I know it’ll engender a lot of bad rep with the old-timers, but I prefer the one on the right.

However, when working on a headless (no monitor) Raspberry Pi it felt like I was pretty much stuck with the nano.

Visual Studio On Raspberry Pi

Until! I discovered Visual Studio Code’s remote extension.

This allowed me to edit my Raspberry Pi files from within Visual Studio Code. So, I get all the joys of writing code directly on my Raspberry Pi, but with all the bells-and-whistles of Visual Studio Code (VSC).

For the most part, setup is pretty straightforward. But the Pi side can get tricky, so I’m going to walk us through the process.

1. Get Visual Studio Code

Download the version of VSC for your PC. Note, you aren’t running this from the Raspberry Pi–instead, you’ll be running it from the PC and connecting it to the Raspberry Pi.

After it’s downloaded and installed open it up.

[ Perdón (forgiveness) pdf free download.

Once open, click here

Ok, now search for the extension called

And hit the Install button. Once it finishes hit the reload button.

Visual Studio Code For Raspberry Pi

The extension works by creating a server which listens for incoming calls from the Raspberry Pi. Once we finished setting up the Raspberry Pi we will use a special command which sends the file on the Raspberry Pi to Visual Studio Code. However, when it’s all done, it’ll look pretty seamless.

Visual studio code raspberry pi docker

Back to setup.

In Visual Studio Code type F1 and type Preferences: Open Workspace Settings

Find the section labeled

We need to change it to true by clicking on the pencil next to its name. This sets the listening server to start every time you open Visual Studio Code.

Almost there. Now to setup the Raspberry Pi. We need to install a program on the Pi which will send a file of our choosing to Visual Studio Code to be edited. RMate was my choice.

Start by SSH’ing into your Raspberry Pi as root.

Visual Studio Code For Raspberry Pi 4

Run an update

Let’s install ruby and supporting packages.

If it installs, then we setup the remote correctly. If not, feel free to ask debugging questions in the comments.

Install Visual Studio Code Raspberry Pi

Now we’ll install the needed Ruby gems.

The above commands install Ruby, moves to to the user’s directory, uses the Ruby package manager to install rmate, then adds Ruby and it’s Gems (packages) executables to the environment variables. All of this is necessary to get Rmate working on Arch Linux.

Ok, let’s test it. Stop SSH’ing into your Pi by typing exit until it brings you back to your PC’s prompt. Now we are going to SSH into the Pi while listening for incoming files to be displayed in Visual Studio Code.

Open Visual Studio Code and open the integrated terminal (if it’s not showing hit CTRL + `).

At the terminal type

Replace the x with your Pi’s ip address.

This should SSH into the Pi while listening for files.

At the pi command prompt, type


This should open a new file called test.js in your Visual Studio Code.

Now you get all the goodness of the VSC IDE, such as syntax highlighting, linting, etc!

A few notes. File permissions still apply, so if you want to be able to save a file the user you logged into on the Raspberry Pi and rmated the file must have write permission on the file.

However, if you do have write permissions, then the “File Save” function in the VSC editor will update the Raspberry Pi file with your modifications. Booyah!

One last annoyance to address. Whenever you want to use VSC to edit your file you have to log into the Pi using

This annoyed me a bit. I could never remember all that. Instead, I created a small bash script to help.

On my PC (for Mac and Linux, Windows, you’re on your own) I created in my home user directory called

And added the following to the file.

Essentially, this script takes your Pi’s login information and logs in to your Pi using the VSC Remote Extension listening.

To get it to work you’ve got to make the file executable

Then login in your Pi like this

Hope you enjoy.

Visual Studio Code For Raspberry Pi

Oh, and for you web-devs, this also works for remote servers. Just replace the Pi with the server.