Running GoLand on a Raspberry Pi 4
Let’s learn how to make GoLand, or any JetBrains IDE, work on a Raspberry Pi 4, a popular development single-board computer.
We’ll cover:
- Requirements
- Installing the Operating System
- Operating System Configuration
- Installing the libraries specific to Raspberry Pi development
- Installing Gnome Desktop Environment
- Installing Go
- Installing Delve
- Installing GoLand
- Using the ARM64 Java Runtime
- Compiling the File Watcher
- IDE Configuration
- Working with the IDE
- Limitations
- IDE Performance
- Remote desktop control
Requirements
Some hardware components are required to follow along with this post:
- Raspberry Pi4 4GB version.
- An adequate power supply.
- An HDMI output cable.
- As the Raspberry Pi 4 will run rather hot, a case with good heat dissipation or some other cooling method is recommended. I chose this case.
Note: A T-Cobbler GPIO extension cable will not fit in the space provided by the case by default, a GPIO raiser header will be needed for that to work. - A good microSD card, as it’s crucial for the operations you will need to run. I used a 32GB Samsung Pro+.
You’ll want something that is well balanced, and you’ll want something that’s good for operations on small files at a good price. To find such a card, you can use websites that have benchmarks on Raspberry Pi storage options.
Alternatively, you can try to boot and use an SSD for your Raspberry Pi 4, which will vastly improve performance, though it will be a bit more complicated.
Installing the Operating System
Download it from http://cdimage.ubuntu.com/releases/19.10/release/, under Preinstalled server image / Raspberry Pi 3 (64-bit ARM) preinstalled server image, e.g. ubuntu-19.10.1-preinstalled-server-arm64+raspi3.img.xz
Flash the image on a microSD card. You can use something like https://www.balena.io/etcher/ to do this.
To connect to our Pi, we’ll use the default username ubuntu and password ubuntu.
Operating System Configuration
Our device has both Ethernet and Wi-Fi capabilities. While connecting an Ethernet cable might be the quick and simple solution, you might not have one available. This response from AskUbuntu explaining how to connect to the wireless network straight from the command line will help in this case.
With our internet connection in place, it’s time to update the OS:
sudo apt update sudo apt upgrade
If you get an error about another update that is in progress, then it is best to wait and retry in about 10-15 minutes.
Installing the libraries specific to Raspberry Pi development
As Raspbian does not yet ship with support for the ARM64 platform, we’ll need to manually add some libraries for our OS and enable the ARMHF platform:
# First, enable the armhf architecture sudo dpkg --add-architecture armhf sudo apt update # Then install the Raspberry dependencies sources sudo add-apt-repository ppa:ubuntu-raspi2/ppa sudo add-apt-repository ppa:ubuntu-pi-flavour-makers/ppa # As ubuntu-raspi2 and ubuntu-pi-flavour-makers don't ship with support for Ubuntu 19.10, we'll need to change the version they use to the 18.04 distribution manually. sed -i 's/eoan/bionic/g' /etc/apt/sources.list.d/ubuntu-pi-flavour-makers-ubuntu-ppa-eoan.list /etc/apt/sources.list.d/ubuntu-raspi2-ubuntu-ppa-eoan.list mv /etc/apt/sources.list.d/ubuntu-pi-flavour-makers-ubuntu-ppa-eoan.list /etc/apt/sources.list.d/ubuntu-pi-flavour-makers-ubuntu-ppa-bionic.list mv /etc/apt/sources.list.d/ubuntu-raspi2-ubuntu-ppa-eoan.list /etc/apt/sources.list.d/ubuntu-raspi2-ubuntu-ppa-bionic.list # Add the current user to a few more groups, needed for some of the dependencies below sudo groupadd -f --system gpio sudo groupadd -f --system i2c sudo groupadd -f --system input sudo groupadd -f --system spi # Finally, install the Raspberry dependencies sudo apt update sudo apt install -y libraspberrypi0:armhf libraspberrypi-bin:armhf libraspberrypi-bin-nonfree:armhf libraspberrypi-dev:armhf libraspberrypi-doc:armhf sudo apt install raspberrypi-sys-mods raspi-config wiringpi pigpio i2c-tools
Installing Gnome Desktop Environment
To run GoLand, we need a desktop environment. For the rest of the article, we’ll be using the Gnome Desktop
sudo apt install -y tasksel sudo tasksel install ubuntu-desktop-minimal
If you get an error that says `tasksel: apt-get failed (100)`, then this means that another update/upgrade process is running in the background. After 10-15 minutes of waiting, it should be safe to try again.
With this done, we can now reboot our device with a `sudo reboot` command and get our desktop environment up and running.
Installing Go
We need to install Go itself, so let’s go to https://golang.org/dl/ and grab the latest stable version for ARM64. At the time of writing this article, this is Go 1.13.8, so we’ll get go1.13.8.linux-arm64.tar.gz.
mkdir ~/gosdks cd ~/Downloads wget https://dl.google.com/go/go1.13.8.linux-arm64.tar.gz tar -C ~/gosdks/ -zxvf go1.13.8.linux-arm64.tar.gz mv ~/gosdks/go ~/gosdks/go1.13.8 # Add Go and GOPATH/bin to our PATH echo 'export PATH="${PATH}:/home/ubuntu/gosdks/go1.13.8/bin:/home/ubuntu/go/bin"' >> ~/.bashrc # Reload our current shell source ~/.bashrc # Test that our changes worked go version
Installing Delve
Delve, the Go debugger, recently received support for the ARM64 platform thanks to this contribution.
We’ll install Delve so that we can debug our applications as the version that ships with the IDE is not compatible with ARM64.
To do so, we can run:
go get -u github.com/go-delve/delve/cmd/dlv
This will download Delve, and compile it into our GOPATH (default under ~/go/). We need to take note of where the location of the Delve binary is, as we’ll need it a bit later on.
Installing GoLand
Now, we can download and install GoLand.
Head over to the website and download the latest version, with a free 30 days trial, or use the free EAP version.
For this post, I downloaded the latest available EAP build, 2020.1 EAP 2.
Once the download has finished, we can unpack it and move it to a new directory:
wget -O golandeap.tar.gz https://download.jetbrains.com/go/goland-201.5259.15.tar.gz tar -C ~/ -zxvf golandeap.tar.gz mv ~/GoLand-201.5259.15 ~/GoLand2020.1EAP
Using the ARM64 Java Runtime
At the time of publishing this post, we don’t ship the IDE with the correct Runtime for the ARM64 platform, so we need to download the correct one from https://bintray.com/jetbrains/intellij-jbr/jbrsdk11-linux-aarch64/722.2#files.
To ensure compatibility with the IDE, we recommend downloading the Runtime that corresponds to the IDE version we have. In this case, it’s `11.0.6+8-b722.2`, and we are interested in the last part, specifically, `722.2`.
Downloading the Runtime and not the SDK is sufficient for running the IDE, so let’s download the file named jbr-11_0_6-linux-aarch64-b722.2.tar.gz. After that, we’ll unpack it and swap the corresponding runtimes.
# First, let's remove the old runtime rm -rf ~/GoLand2020.1EAP/jbr # Fetch and unpack the new one wget -O jbr.tar.gz https://bintray.com/jetbrains/intellij-jbr/download_file?file_path=jbr-11_0_6-linux-aarch64-b722.2.tar.gz tar -C ~/GoLand2020.1EAP/ -zxvf jbr.tar.gz
Compiling the File Watcher
The next step is to compile the File Watcher that’s native to our ARM64 platform. The complete instructions can be found here: https://confluence.jetbrains.com/display/IDEADEV/Compiling+File+Watcher. This script can also help us download the files we need: https://gist.github.com/dlsniper/97ca1287df1418aef413c465adeac6df
And don’t forget to adjust the inotify(7) instances and watches limits.
With the correct Runtime now in place, and the correct File Watcher binary compiled, we can now start the IDE. We can do so by running:
JAVA_HOME=~/GoLand2020.1EAP/jbr ~/GoLand2020.1EAP/bin/goland.sh &
IDE Configuration
Since this is the first time we are starting the IDE, we need to do a bit of configuration before creating a project.
Click on the Configure button, then select the Edit Custom Properties action, add the following line, then restart the IDE:
“`idea.filewatcher.executable.path=fsnotifier-aarch64
dlv.path=/home/ubuntu/go/bin/dlv“`
The entry should look like this:
Before we restart the IDE, let’s make one last configuration change.
Press the Find Action shortcut, Ctrl+Shift+A, to bring up the dialog and search for Registry…
Open this and search for run.process.with.pty by typing in the window, then disable it by clicking on it.
Now, we can close the IDE and start it again.
Working with the IDE
After all this setup is done, all the familiar IDE features, such as code completion, refactorings, running of applications, or debugging them should work as they work on a regular desktop computer.
Limitations
The built-in terminal doesn’t work at the moment due to an incompatibility with the underlying libraries used, subscribe to https://github.com/JetBrains/pty4j/issues/82, and you’ll receive an update as soon as the issue is solved.
We’ll update the article when these limitations are removed, or if new ones are discovered.
IDE Performance
The big question is: Will the IDE be usable given the limited hardware?
To my surprise and delight, the operations work somewhat smoothly, at least well over my expectations.
So, I ran a couple of ad-hoc tests to check the difference in speed between the Raspberry Pi 4 with 4GB RAM running Ubuntu 19.10 ARM64 and my laptop, which has an Intel Core i7 6700HQ with 32GB RAM and Windows 10.
Unsurprisingly, my Windows laptop is faster, but here are the results:
Raspberry Pi | Laptop | |
---|---|---|
Startup time | 29 seconds | 9 seconds |
Indexing of github.com/influxdata/flux | 93 seconds | 12 seconds |
As mentioned earlier, you can improve these by running the from an SSD, but this will make the initial setup a bit more complex.
Remote desktop control
Controlling a Raspberry Pi might be more comfortable in some cases if it’s done remotely.
How do we do this? RealVNC is here to save the day.
Let’s install the VNC Server so that we can control our setup remotely from the comfort of our computer.
Normally, RealVNC comes bundled with Raspbian, but since we are running Ubuntu using ARM64 architecture, we need to install some additional dependencies before we can continue:
sudo apt install -y libc6:armhf libbsd0:armhf libx11-6:armhf libxau6:armhf libxcb1:armhf libxdmcp6:armhf libxext6:armhf libxtst6:armhf wget https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.7.1-Linux-ARM.deb -O /tmp/VNC-Server-6.7.1-Linux-ARM.deb sudo dpkg -i /tmp/VNC-Server-6.7.1-Linux-ARM.deb
To start this, we can run
sudo systemctl start vncserver-x11-serviced.service
To make this service run on startup:
sudo systemctl enable vncserver-x11-serviced.service
Note: Using the RealVNC server to remote control your Raspberry Pi 4 device will incur a pretty big performance penalty, with CPU spikes of up to 50% usage, and constant usage above 15%, so your development experience might suffer.
This concludes our guide on getting started with Go development on a Raspberry Pi using GoLand. In it, we first learned how to install Ubuntu 19.10 ARM64, then we installed Go, Delve, and GoLand. Finally, we set up RealVNC to enable us to remotely control the device, even if we don’t have a screen attached to it.
Let us know your questions and feedback in the comments section below, the issue tracker, or our Twitter account.