Scott Hanselman

Building Visual Studio Code on a Raspberry Pi 3

March 15, '16 Comments [34] Posted in Hardware | Open Source
Sponsored By

Visual Studio Code running on a Raspberry Pi 3 - Michonne Approves

I picked up a Raspberry Pi 3 recently for MarchIsForMakers. The Raspberry Pi 3 is a great starter computer for makers not just because it is faster than the Pi and Pi 2, but because it has Wifi built in! This makes setup and messing around a lot easier.

Here's some great tutorials for getting started with the Raspberry Pi, Node, and Visual Studio Code.

I also recommend folks setup a VNC Server for their Raspberry Pi so you can TightVNC (meaning, remote in and control) into the Pi from your PC. You can also setup your Raspberry Pi to share the clipboard so you can copy from Windows and Paste into the VNC window when you are remoted into your Pi.

But why not build Visual Studio Code and get it running natively on the Pi? Marc Gravell did it first on Twitter, but I wanted to figure out how he did it and if it was still possible (he did it before some significant refactoring) and also to see if VS Code was faster (or even usable) on a Rasberry Pi 3.

Compiling Visual Studio Code on a Raspberry Pi 3

From the VS Code GitHub, you need Node, npm, and Python. The Pi has Python but it has an old node, so needed a newer node that ran on ARM processors.

get http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb

There are some NPM native modules like node-native-keymap that didn't work when I built the first time, so you'll need some supporting libraries first:

sudo apt-get install libx11-dev

Then, from my Raspberry Pi, I did this to build my own instance of VS Code.

git clone https://github.com/microsoft/vscode
cd vscode
./scripts/npm.sh install --arch=armhf

This took the Raspberry Pi 3 about 20 minutes so be patient.

Then, run your instance with ./scripts/code.sh from that same folder.

Note: Electron and Chromium underneath it use some very specific features of X Servers like "xrandr" for dynamic resizing and you may have trouble getting Visual Studio Code to run under a remote VNC session. Consider using RealVNC or TigerVNC for your Raspberry Pi, rather than the older TightVNC. RealVNC is a commercial product but they'll give you a free license for your Raspberry Pi.

Once you've updated to a newer VNC you can run VS Code

image

Check out MarchIsForMakers all month long as we partner with CodeNewbies and play and learn with maker hardware! Last week we unboxed my Raspberry Pi 3, set it up, and got it to blink an LED!

What have YOU done with your Raspberry Pi? Sound off in the comments.


Sponsor: Big thanks to Redgate for sponsoring the feed this week! Feeling the pain of managing & deploying database changes by hand? New Redgate ReadyRoll creates numerically ordered SQL migration scripts to take your schema from one version to the next. Try it free!

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.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Tuesday, March 15, 2016 9:05:25 PM UTC
You can try Nomachine instead of VNC for better experience similar to remote desktop: https://www.nomachine.com/tips-on-how-to-set-up-your-raspberry-pi-for-remote-access-via-nomachine
Omer Celik
Tuesday, March 15, 2016 9:08:31 PM UTC
Great work!
Tuesday, March 15, 2016 10:22:19 PM UTC
My 3 is arriving on Thursday, I'm excited. :) Was Visual Studio Code pretty usable?
Tuesday, March 15, 2016 10:49:43 PM UTC
Rick - Slow to start but reasonable to use. Another better way is to just use Code talking to a Samba remote share
Scott Hanselman
Tuesday, March 15, 2016 10:54:16 PM UTC
I thought the idea was to develop FOR the pi, not ON the pi... :p
I'm loving win 10 IoT with Pi2, my Pi3 arrives today, sadly the day after Pi day.
Wednesday, March 16, 2016 5:12:10 AM UTC
Or you can keep Code on your PC and you can automatically sync your code with the PI through SSH. I did it using a plugin.
evdin
Wednesday, March 16, 2016 6:03:10 AM UTC
Is there some particular reason you do not obtain the Node package over HTTPS, like a deranged cert store or a TLS-incapable fetching tool?

Seeing packages installed system-wide from HTTP sources screams out at me :)
Lars Viklund
Wednesday, March 16, 2016 8:23:02 AM UTC
Which was OS version in Pi3 you had tried? Windows 10 IOT?
Anto
Wednesday, March 16, 2016 8:46:31 AM UTC
Currently setting up my PI 1 as a time lapse camera (not overly concerned if i lose it)

I have my PI 2 set up as a security camera using motion pie

And i am planning to use my PI 3 to help control the temperature of my fermenting beer (turning heater/ fan on and off to keep a steady temperature).

I haven't thought of a good use for the PI zero.... yet.

P.
Wednesday, March 16, 2016 10:12:16 AM UTC
MarchIsForMakers link doesn't have any reference
Alaeddin Hussein
Wednesday, March 16, 2016 12:04:06 PM UTC
The MarchIsForMakers link has two issues: "fro" instead of "for" and a "," before "com".
John P
Wednesday, March 16, 2016 8:59:13 PM UTC
Hi Scott, I'm using Rasperry Pi 2 together with http://www.openhab.org/ to control my home elektronics over the a knx bus. Compared to commercial KNX "Servers" you save tons of money and it is fun :-)
Wednesday, March 16, 2016 10:43:40 PM UTC
Once you've built it if you add alias vscode='.~/vscode/scripts/code.sh' to the bottom of your .bashrc file in your home directory, you can just type vscode <filename> to launch it.

Andy Ross
Thursday, March 17, 2016 9:18:34 PM UTC
Currently running VSCode on a out the box Raspbian image. Had to uninstall the default Node and Node-Red packages but apart from that runs like a dream.
Thanks foe the tutorial.
Jim Hurst
Friday, March 18, 2016 2:11:35 AM UTC
I've had a lot of awesome with xrdp on my raspberry pi 2. VNC is alright, but when connecting from a windows box, it's so much more natural to just open up remote desktop and pop right on your pi. I find it best to set the window size in the connection settings before connecting however, particularly if you have a large resolution monitor.
Friday, March 18, 2016 5:45:45 PM UTC
Thanks for this tutorial ,I haven't thought of a good use for the PI .
Saturday, March 19, 2016 2:45:42 AM UTC
Thanks Scott.

You might want to update the first command to use 'wget' instead of 'get'.
Saturday, March 19, 2016 6:07:39 AM UTC
Huge shout out to Jessica Lord (https://twitter.com/jllord) who basically single-handedly did a shitton of work to get the ARM build of Electron working (and by extension, VS Code)
Sunday, March 20, 2016 3:39:58 PM UTC
It also works very well with x11vnc and xrdp. Finally, we have good code editor for raspberry pi.
Alex Furman
Monday, March 21, 2016 2:32:28 AM UTC
Most people look at a problem and say why... thank goodness there are a select few like Scott that say "why not".
Monday, March 21, 2016 12:40:04 PM UTC
Deploying and debugging your application is straightforward with Visual Studio. We’ll use the Remote Debugging feature to deploy the app to your locally connected IoT Core device.
Monday, March 21, 2016 5:08:43 PM UTC
Hi all,

I have a general question which sparks my interest. What do you think are the industries with the most software developers, except for finance and software development vendor/consultancy industries?
GiuseppeRollo
Tuesday, March 22, 2016 1:28:51 PM UTC
Thursday, March 24, 2016 7:20:36 PM UTC
Wait....! :o
Debian? Python?
Why can't we have Windows and C# presented?
OK, Windows may not be so full of features as this Linux on these devices, but with Windows Core you can catch up, can't you?
Is MS gaining something out of this Pi/Debian/Python except for users that may use VS Code to do the coding?
And why are people at MS so excited with Pi?
I know it is exiting for individuals, but why for MS?
Does MS have stock shares in Pi, are they partners with them or what? :^)
I am confused about what is the company strategy here... :(
I understand the "empowering people" moto, but you have to also make money, don't you? :^)
Does the cloud provide so much money that you don't need other sources of income or what? :^)

Good LED blinking video anyway. :)
Not sure I have the time/energy/mood/money to start playing with hardware (especially if I can't get the whole set of tools with one purchase order), but at least you have tempted me.
I find Visual Studio a much better toy to play with... One might need more infrastructure to blink LEDs, but I have a full screen of microscopic LEDs already to blink anyway...
Thursday, March 24, 2016 7:25:37 PM UTC
Thanks! it worked 100%.
Only one small thing, nodejs-legacy hast to be uninstalled before you can install the latest version.
bernardo
Tuesday, March 29, 2016 1:52:03 PM UTC
@Me You can use the Pi as a simple device to do programming on, and it's only $35 or around there. MS probably just wants anyone to be able to learn programming/computer science without having to spend a lot of money.
Frank
Monday, April 04, 2016 2:54:39 AM UTC
I believe you may have dropped a w?
get http://node-arm.herokuapp.com/node_latest_armhf.deb
s/b
wget http://node-arm.herokuapp.com/node_latest_armhf.deb

Sunday, April 10, 2016 1:52:02 PM UTC
Thanks for any other wonderful article. Where else could anyone get that type of info in such an ideal way of
writing? I've a presentation next week, and I am on the look for such info.
Friday, April 15, 2016 8:23:49 AM UTC
It worked great, thanks.

Coming from c#, I wanted to dig a little into python development. I am only getting used to VS Code on Windows, so I want to stick with it on my Pi.

Only thing I had to do in addition was to first update the legacy version of node before installing the latest arm version:

sudo apt-get update
sudo apt-get install node
Michael
Saturday, April 16, 2016 5:52:02 PM UTC
yeah *wget
really cool stuff, love coding on my pi 3
before installing the new node:
sudo apt-get uninstall node node-legacy
greg
Saturday, April 23, 2016 3:40:48 PM UTC
Great job! Now I'm running on PI 2.
Thursday, May 05, 2016 8:58:53 AM UTC
Congrats to you :). Will you launch this in open marketing for sale. is something different about this. How curious to know.. :)
Friday, May 20, 2016 1:11:38 PM UTC
compile also on PI2
valeriano cossu
Name
E-mail (will show your gravatar icon)
Home page
 
Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, li, ol, pre, strike, strong, sub, super, u, ul) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.
Live Comment Preview

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.