Sponsored By
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. Accessory parts. In addition to a Windows PC (Win7, Win 8, Windows 10) you need a Raspberry Pi with user interface. Raspbian (no Lite version) with installed desktop is recommended.If you are new to Visual Studio, C #,.NET, and GUI building, we recommend a small but helpful guide.In addition, Visual Studio must be on our computer.
- You can run Visual Studio Code on Raspberry Pi devices. By downloading and using Visual Studio Code, you agree to the license terms and privacy statement. 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.
- Microsoft’s Visual Studio Code is an excellent C development environment, and now it’s an easy install on Raspberry Pi. Here’s Jim Bennett from Microsoft to show you all how to get VS Code up and running on our tiny computer.
- Select the Extensions tab from the sidebar menu, then search for Remote development. Select the Remote Development extension, and select the Install button. Next you can connect to your Raspberry Pi. Launch the VS Code command palette using Ctrl+Shift+P on Linux.
Four years ago I wrote how to BUILD (literally compile) Visual Studio Code for a Raspberry Pi ARM machine. Just a few months later in November, community member Jay Rodgers released his labor of love - nightly builds of VS Code for Chromebooks and Raspberry Pi.
If you want to get unofficial builds of Visual Studio Code running on a Raspberry Pi (I know you have one!) you should use his instructions. He has done a lot of work to make this very simple. Head over to http://code.headmelted.com/ and make it happen for yourself, now!
Jay says:
I've maintained the project for a few years now and it has expanded from providing binaries for Pi to providing support and tools to get VS Code running on low-end ARM devices that might not otherwise support it like Chromebooks (which make up about 60% of the devices in schools now).
![Visual Studio Code Raspberry Pi 4 Visual Studio Code Raspberry Pi 4](https://dev.to/social_previews/article/97301.png)
The project has really taken off among educators (beyond what I would have thought), not least because they're restricted to the devices provided and it gives them a route to teach coding to students on these computers that might not otherwise be there.
Again, Jay is doing this out of love for the community and the work that makes it happen is hosted at https://github.com/headmelted/codebuilds. I'd encourage you to head over there right now and give him a STAR.
There's so many community members out there doing 'thankless' work. Thank them. Thank them with a thank you email, a donation, or just your kindness when you file an issue and complain about all the free work they do for you.
I just picked up a Raspberry Pi 4 from Amazon, and I was able to get a community build of VS Code running on it easily!
Open a terminal, run 'sudo -s' and then this script (again, the script is open source):
Jay has done the work! That's just the apt instructions, but he's got Chrome OS, APT, YUM, and a manual option over at http://code.headmelted.com/!
Thank you for making this so much easier for us all.
Love Raspberry Pis? Here's some fun stuff you can do with the Raspberry that you bought, the one you meant to do fun stuff with, and the one in your junk drawer. DO IT!
- You can even install this week's sponsor Couchbaseon a Raspberry Pi!
Enjoy!
Sponsor: Couchbase gives developers the power of SQL with the flexibility of JSON. Start using it today for free with technologies including Kubernetes, Java, .NET, JavaScript, Go, and Python.
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.
AboutNewsletter
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
.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.
[
Once open, click here
Ok, now search for the extension called
And hit the
Install
button. Once it finishes hit the reload button.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.
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.
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.
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
[
![Raspberry Raspberry](/uploads/1/3/7/3/137397230/444302661.png)
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.
Install Visual Studio Code On Raspberry Pi 4
Essentially, this script takes your Pi’s login information and logs in to your Pi using the VSC Remote Extension listening.
Visual Studio Code Raspberry Pi 4 Plus
To get it to work you’ve got to make the file executable
Then login in your Pi like this
Hope you enjoy.
Oh, and for you web-devs, this also works for remote servers. Just replace the Pi with the server.