The Best! Open-Source Development Environment for Raspberry Pi Projects
When getting started doing projects on small devices like Raspberry Pi's (and smaller), it can be hard to establish a comfortable workflow during development. I mean comfortable literally - ergonomically, as a human - as well as being able to utilize familiar, modern development tools.
Having to be physically tethered to any device in order to do development might be impractical or inconvenient for various reasons. I always setup my Pis with a wifi dongle, config for connecting to my wifi and with SSH enabled. This allows me to login to the pi over wifi using SSH without ever having to plug in a keyboard or monitor. While this puts the remote into remote development, it doesn't provide the full experience of using an IDE and other tools that really benefit from having a GUI ( like git ).
But what about the source code? Frequent code changes during development mean those files need to get updated on the remote server, the pi. This either means using a command line tool like emacs, vim, etc, or constantly copying files between machines. This situation smells bad. Code is going to get out of sync, overwritten, or lost. Of course git should handle all official business, it doesn't solve the challenge simulating edits (uncommitted changes) between machines during development.
Over the years I have tried a few solutions (usually plugins to IDEs) that tried to synchronize a local copy of a file with a remote machine and it never worked right. I always wanted a solution where I could modify files directly on the remote machine, but using an application on my workstation.
So how did I eventually win using 100% free and open source technologies? The rest of this article will outline a great solution I found using VSCode and a plugin called 'Remote - SSH'.
Remote - SSH
Pretty much just like it sounds. A free extension developed by Microsoft themselves. I won't overstate my technical understanding here but it uses SSH and a small client application installed on the remote machine to allow VSCode to open a remote directory as if it were any other directory. A window to the server to make a Microsoft reference.
There are no file-copying-syncing shenanigans. This is the essential difference with this setup: there is just one copy of source code on the server.
Opening a remote window can be a little tricky, this weird icon gets you started:
You need to provide username@ip and then VSCode will allow you to browse and open directories on the remote machine as if they were local to the workstation.
So in practice... I sit wherever I am comfortable ( and have network access to the pi ) and I can work on the remote pi just as if it were the local workstation itself. By that I mean that through VSCode + the plugin I've got access to terminals, a git GUI, and all the other benefits of the IDE like syntax highlighting, code navigation, completion etc.
Outside of VSCode the pi is just another device on the network from the workstation's perspective. This is often how the pi/project/app is accessed ( via its IP:port on the local network ) , so its a very convenient testing setup. Just tabbing between windows on the keyboard entirely shifts the perspective of my keystrokes from being on the pi, to being a client of the pi.
An additional benefit of this setup is the developer workstation never needs to clone the git repositories being developed. The workstation is a somewhat-expendable piece of the picture.
Docker / arm32v7
If you're using docker on the Pi ( specifically the model 2 and 3 I think ) you will quickly learn that you can't run just any image because these platforms use the arm32v7 architecture. Again, not trying to pretend that I can explain that thoroughly, but basically this is a really low level hardware difference. The simple way of saying that is that you'll need to build and run your docker images on the pi using 'arm32v7 compatible' images. I wrote a post about this.
Conclusions
Compared to the alternatives, this is obviously a more comfortable and modern development setup. Dealing with multiple remote machines makes a setup like this a requirement. A few things that can additionally smooth the workflow are placing SSH keys on remote machines for password-less logins and setting up git credential store.
And of course, I would recommend that you use docker on the Pi also, but that goes beyond what I intended to explain here.
How many open source wins is this?
- Running Ubuntu OS on development machine
- Raspberry Pi / Raspbian OS
- VSCode + the plugin
- ( are we counting git, SSH? )
Update: 3/2022
I found that the remote host ( the pi ) was getting bogged down, and found the solution in the following article was the one I needed: