#VSCode – Installing Visual Studio Code in a #RaspberryPi, a couple of lessons learned – @code

Hi!

Now that I have my amazing Raspberry Pi 4 with 4GB RAM, it’s time to see how serious the device is. So, I decided to install and use some developers’ tools in the RPi. My dev list will be something like this

  • Python
  • Some ML and AI Python packages
  • GIT
  • Arduino
  • Visual Studio Code

It’s been a while since I installed VSCode in the device. The last time I did this, I needed to download the code from GitHub and compile the tool in the Raspberry Pi. As far as I remember this was a +25 min process.

Lucky for us the process can now be much simpler, thanks to Headmelted (see references). Now, we only need a single command to install VSCode:

. <( wget -O -
https://code.headmelted.com/installers/apt.sh )

Install process started! Or Maybe not because I found this amazing GPG error

python error installing visual studio code in raspberry pi
pi@rpidev3:~ $ curl -L https://code.headmelted.com/installers/apt.sh | sudo bash
   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                  Dload  Upload   Total   Spent    Left  Speed
 100  2349    0  2349    0     0  19739      0 --:--:-- --:--:-- --:--:-- 19906
 Detecting architecture…
 Ensuring curl is installed
 Reading package lists… Done
 Building dependency tree       
 Reading state information… Done
 curl is already the newest version (7.64.0-4).
 The following packages were automatically installed and are no longer required:
   python3-pyperclip python3-thonny rpi.gpio-common
 Use 'apt autoremove' to remove them.
 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
 Architecture detected as armv7l…
 Retrieving GPG key headmelted…
   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                  Dload  Upload   Total   Spent    Left  Speed
   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
 gpg: no valid OpenPGP data found.
 Removing any previous entry to headmelted repository
 Installing [headmelted] repository…
 Updating APT cache…
 Hit:1 http://raspbian.raspberrypi.org/raspbian buster InRelease
 Hit:2 http://archive.raspberrypi.org/debian buster InRelease
 Get:3 https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease [23.4 kB]
 Err:3 https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease
   The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0CC3FD642696BFC8
 Reading package lists…
 W: GPG error: https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0CC3FD642696BFC8
 E: The repository 'https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease' is not signed.
 Done!
 Repository install complete.
 Installing Visual Studio Code from [stretch]…
 Reading package lists… Done
 E: The value 'stretch' is invalid for APT::Default-Release as such a release is not available in the sources
 Visual Studio Code install failed.

There a public GPG key used to verify the package and the SH script somehow does not download it (I think the ARM RPI version is still not defined). So, before the previous command, I need to run these commands

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

Then run this command

curl -L https://code.headmelted.com/installers/apt.sh | sudo bash

Now we have Visual Studio Code installed!

raspberry pi visual studio code installed

But, yes another but, you may note that the tool open and display a black window. Again, I need to go deeper on the details, but the latest version does not work well. There is some context information on GitHub (see references), and the proposed solution is to rollback to a previous version

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

And we also need to disable the automatic updates on this tool

sudo apt-mark hold code-oss

And now, yes, we got a fully functional Visual Studio Code in our Raspberry Pi!

Happy Coding!

Greetings @ Toronto

El Bruno

References

My posts on Raspberry Pi ⚡🐲⚡

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware

16 comments

  1. Dear Sir,
    First of all, I want to thank you about your blog about object detection using YOLO. Thereafter, I’m a beginner in AR, VR and I want to try deploy an example of object detection on HoloLens using YOLO. Therefore, can you please give me some details about the instructions to deploy the YOLO library to Unity to HoloLens. Certainly, I will be among the most followers of your blogs. Thank you for helpfulness.
    Best regards

    Like

  2. I was unable to install VS Code because the GPG key wasn’t created. I used the following:

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

    but got the following error. I could use some advice, please.

    pi@raspberrypi:~ $ wget https://packagecloud.io/headmelted/codebuilds/gpgkey -O- | sudo apt-key add –
    –2020-09-03 20:48:35– https://packagecloud.io/headmelted/codebuilds/gpgkey
    Resolving packagecloud.io (packagecloud.io)… 54.193.34.251, 54.215.161.51, 2600:1f1c:2e5:6900:dbad:ab75:d3df:6840, …
    Connecting to packagecloud.io (packagecloud.io)|54.193.34.251|:443… gpg: can’t open ‘–’: No such file or directory
    connected.
    HTTP request sent, awaiting response… 302 Found
    Location: https://d28dx6y1hfq314.cloudfront.net/3487/3704/gpg/headmelted-code-oss-0CC3FD642696BFC8.pub.gpg?t=1599184416_9e339607b3be2d46f1b20f02e70b504863f3f7f0 [following]
    –2020-09-03 20:48:36– https://d28dx6y1hfq314.cloudfront.net/3487/3704/gpg/headmelted-code-oss-0CC3FD642696BFC8.pub.gpg?t=1599184416_9e339607b3be2d46f1b20f02e70b504863f3f7f0
    Resolving d28dx6y1hfq314.cloudfront.net (d28dx6y1hfq314.cloudfront.net)… 13.249.64.181, 13.249.64.22, 13.249.64.79, …
    Connecting to d28dx6y1hfq314.cloudfront.net (d28dx6y1hfq314.cloudfront.net)|13.249.64.181|:443… connected.
    HTTP request sent, awaiting response… 200 OK
    Length: 3949 (3.9K) [text/plain]
    Saving to: ‘STDOUT’

    – 0%[ ] 0 –.-KB/s in 0s

    Cannot write to ‘-’ (Broken pipe).

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.