How to Build Sonic Pi in a Debian Jessie Chroot

Sonic Pi running in a chroot

(All the nitty-gritty details, ironed out after hours of frustration)

Sonic Pi is a music synthesizer powered by code. Instead of playing on a keyboard and turning knobs, a performer writes code on the fly. To progress the music, change the code. I’ve been trying to explore ways to perform music live for some time, and combining music and code is too good for me to overlook.

A chroot is a feature on Linux and other Unix-like systems that changes the root directory that appears to a process. In effect, it means programs can run in a sort of “mini OS” in a folder of the main OS, without affecting any files outside of it. I wanted to run Sonic Pi in a chroot because I don’t want to leave extra libraries and stuff lying around in case I decide I no longer want to use it.

Debian Jessie is the latest release of… Okay, that’s enough.

Update: Sonic Pi is available as an official package since Debian Stretch, which was first released in June 2017. You should use the official package if you can. This is probably not the best way to use a chroot; this was more of a personal experiment. Also, the build process appears to have changed in newer versions of Sonic Pi, so this guide may no longer be useful.


A lot of the work I did is “extra” based on my personal preferences, so here’s a simpler how-to first:

How to Build Sonic Pi in Debian Jessie with Minimal Effort

Warning: I have not tested this all the way through, so it may not work as is. Any corrections and suggestions for improvement are appreciated.

Step 1: Download Source Code

Download the source code from GitHub. I’m using version 2.11.1. Unpack it somewhere convenient.

Step 2: Modify the Build Script

The Sonic Pi developers have written a handy script, app/gui/qt/build-ubuntu-app, that is supposed to provide a “one-step” build. But we’ll have to change it a bit.

First, we need to make some changes to the line that installs the dependencies:

sudo apt-get install -y g++ ruby # etc., etc.
  • Replace libboost1.58-dev (or libboostX.XX-dev ) with libboost-dev. (Jessie has only version 1.55, and it seems to work fine.)
  • Take out libqwt-qt5-dev. (Sonic Pi requires Qt 5, but Jessie has Qwt only for Qt 4.)
  • Add jackd2. (For some reason this doesn’t get pulled in.)

Second, uncomment the section marked with ### IF YOU HAVE PROBLEMS WITH qwt. (Yes, there are problems, as described earlier.)

Step 3: Run the Build Script

Run app/gui/qt/build-ubuntu-app and let it do its magic. (I think you need to cd into the directory first or else the paths don’t work.)

Step 4: Run Sonic Pi

Run bin/sonic-pi and enjoy!

Note: If you want to just type sonic-pi and be done with it, you might be tempted to make a symbolic link from /usr/local/bin/sonic-pi. But don’t, because it breaks some path-detecting magic. Instead, put the bin folder in your PATH, or put a script in /usr/local/bin that runs the original:

#!/bin/sh
exec /path/to/sonic-pi.../bin/sonic-pi

And now we get to the real how-to:

How to Build Sonic Pi in a Debian Jessie Chroot with Extra (Read: Unnecessary) Effort

The extra effort falls into two broad categories:

  1. Dealing with the chroot, which means extra work dealing with JACK
  2. “Manually” building dependencies from source, which means not using the build script (but still using it as a guide)

Step 1: Prepare the Chroot

Debian has a nice program called debootstrap that sets up a minimal Debian system in a directory:

main$ sudo apt-get install deboostrap # If needed
main$ mkdir sonic-pi-chroot
main$ sudo debootstrap jessie sonic-pi-chroot/ http://deb.debian.org/debian

The chroot is missing a few essential programs, so install them inside the chroot:

main$ sudo chroot sonic-pi-chroot/
chroot# apt-get install git bzip2 python dbus-x11

We’ll also make a regular user account to run things instead of having root do all the work:

chroot# adduser someuser
chroot# apt-get install sudo
chroot# usermod -a -G sudo someuser
chroot# su someuser

(The following steps assume that a regular user account is building.)

Step 2: Install Dependencies

One thing I learned the hard way is don’t try to hunt for dependencies yourself. Just copy the apt-get line from the build script app/gui/qt/build-ubuntu-app (with the same modifications as in the “minimal effort” method) and run it.

Step 3: Install Qwt

Download the Qwt source code from SourceForge. I’m using version 6.1.3. Unpack it somewhere and build it:

chroot$ wget -O qwt-6.1.3.tar.bz2 "https://some-sourceforge-mirror-link.example"
chroot$ tar xf qwt-6.1.3.tar.bz2
chroot$ cd qwt-6.1.3
chroot$ qmake qwt.pro
chroot$ make
chroot$ sudo make install

Then, we need to deal with Qwt’s rather unorthodox library placement:

chroot$ sudo cp /usr/local/qwt-6.1.3/features/* /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/
chroot$ echo "/usr/local/qwt-6.1.3/lib" | sudo tee /etc/ld.so.conf.d/qwt.conf
chroot$ sudo ldconfig

Step 4: Install SuperCollider

Download the source code from SuperCollider’s website. I’m using version 3.8.0. Unpack and build:

chroot$ wget https://github.com/supercollider/supercollider/releases/download/Version-3.8.0/SuperCollider-3.8.0-Source-linux.tar.bz2
chroot$ tar xf SuperCollider-3.8.0-Source-linux.tar.bz2
chroot$ cd SuperCollider-Source
chroot$ mkdir build
chroot$ cd build
chroot$ cmake -DCMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu/ -DSC_EL=no ..
chroot$ make
chroot$ sudo make install

Step 5: Install SC3

Download the source code from GitHub. I’m using version 3.8.0, corresponding to SuperCollider. Unpack:

chroot$ wget https://github.com/supercollider/sc3-plugins/archive/Version-3.8.0.tar.gz
chroot$ tar xf Version-3.8.0.tar.gz
chroot$ cd sc3-plugins-Version-3.8.0

There are two external dependencies we need to deal with. They’re included on GitHub as Git submodules, but this isn’t a clone.

First is STK. Just install the distribution package:

chroot$ sudo apt-get install libstk0-dev

Second is Nova SIMD. That doesn’t have a package, so clone the repository on GitHub into the external_libraries directory:

chroot$ cd external_libraries
chroot$ rmdir nova-simd
chroot$ git clone https://github.com/timblechmann/nova-simd.git

Then we can build SC3. Notice that I set SYSTEM_STK so CMake uses the system-installed STK:

chroot$ cd ..
chroot$ mkdir build
chroot$ cd build
chroot$ cmake -DSC_PATH=/usr/local/include/SuperCollider/ -DSYSTEM_STK=1 ..
chroot$ make
chroot$ sudo make install

Step 6: Install Aubio

Download the source code from Aubio’s website. I’m using version 0.4.4. Unpack and build:

chroot$ wget https://aubio.org/pub/aubio-0.4.4.tar.bz2
chroot$ tar xf aubio-0.4.4.tar.bz2
chroot$ cd aubio-0.4.4
chroot$ ./waf configure
chroot$ ./waf build
chroot$ sudo ./waf install

Step 7: Build Sonic Pi

chroot$ cd /path/to/sonic-pi.../app/gui/qt
chroot$ ../../server/bin/compile-extensions.rb
chroot$ cp -f ruby_help.tmpl ruby_help.h
chroot$ ../../server/bin/qt-doc.rb -o ruby_help.h
chroot$ lrelease SonicPi.pro
chroot$ qmake SonicPi.pro
chroot$ make

Step 8: Prepare a Few Things for JACK

JACK needs to access the audio devices in the main root, so bind-mount /dev and /dev/shm (JACK uses /dev/shm for its shared memory):

main$ sudo mount --bind /dev sonic-pi-chroot/dev
main$ sudo mount --bind /dev/shm sonic-pi-chroot/dev/shm

Then, back in the chroot, add the user account created earlier to the audio group, so it can use realtime audio:

chroot$ sudo usermod -a -G audio someuser

Step 9: Run JACK

The secret that could probably have saved me many of those hours of frustration is run JACK in the chroot! The entire time I tried running JACK in the main system and it kept failing. I don’t quite know why.

I’m using QJackCtl to manage JACK:

chroot$ qjackctl &

Step 10: Run Sonic Pi (Finally!)

The executable is /path/to/sonic-pi.../bin/sonic-pi

chroot$ /path/to/sonic-pi.../bin/sonic-pi &

You can do the same script thing as in the “minimal effort” version so you can just type sonic-pi.


Whew, that was quite a ride. Again, not all of this effort is strictly necessary. Even so, I hope this helps you get Sonic Pi running. Have fun!

Reply to this post on: Medium
Philip Chung
Philip Chung
Software Developer