Installing SBCL on Uberspace

Uberspace does not provide SBCL by default, so you will have to install it yourself in order to use it for your Common Lisp server application. Since Uberspace is a shared hoster, SBCL has to be installed to your home directory. This requires either some environment variables to be set or SBCL to be compiled with a different prefix. Additional information related to installing/building SBCL can be found in the INSTALL file comming with the SBCL source/binary distribution or on the SBCL homepage.

Binary distribution

The easiest way to install SBCL is to use the binary distribution you can get from the download page. Download the latest version for Linux/AMD64 from the platform table to your Uberspace, unpack it, and go into the directory, e.g. (without linebreaks):

$ wget http://prdownloads.sourceforge.net/sbcl/sbcl-1.2.4-x86-64-linux-binary.tar.bz2
$ tar -xjf sbcl-1.2.4-x86-64-linux-binary.tar.bz2
$ cd sbcl sbcl-1.2.4-x86-64-linux/

To install SBCL to the home directory (i.e., to ~/bin, ~/lib, etc., which are also used by other applications on your uberspace), run the install script with INSTALL_ROOT set to your home directory (so exchange chfin with your actual username):

$ INSTALL_ROOT=/home/chfin sh install.sh

The installation procedure will probably complain about missing documentation files, which you can ignore. Before that it should say something like

SBCL has been installed:
 binary /home/chfin/bin/sbcl
 core and contribs in /home/chfin/lib/sbcl/

The third line is important as it tells us that SBCL’s core has been installed to /home/chfin/lib/sbcl/. SBCL by default looks for its core under /usr/local/lib/sbcl/, since /usr/local is the default prefix. To make SBCL find its core in /home/chfin/lib/sbcl, we either have to build it with the prefix /home/chfin or set the environment variable SBCL_HOME to the core directory:

$ export SBCL_HOME=/home/chfin/lib/sbcl

To make this permanent, add the previous line to your ~/.bash_profile, log out and log in again. This should give you

$ sbcl --version
SBCL 1.2.4

Compiling from source

This uses a lot of system resources and should *not* be done more often than absolutely necessary on a shared hoster like Uberspace.

Compiling from source has the advantage that you can provide a prefix that SBCL is installed to and that it uses to search for its core, so you don’t have to set SBCL_HOME. Also, the usual benefits of compiling from source apply like adding/removing features.

To compile SBCL, you need an already compiled SBCL or another Lisp implementation that is able to compile SBCL (refer to the the INSTALL for a complete list). The easiest way is to use an already installed SBCL (as described in the previous section) or a simply unpacked binary distribution. Fetch the sbcl source by downloading the source tarball or cloning the git repo (don’t forget to checkout the latest release tag) and navigate to the source directory.

To compile SBCL using an already installed SBCL just run

$ sh make.sh --prefix=/home/chfin

replacing chfin with your username. Of course, you can add other options to make.sh to customize your build according to INSTALL.

If you didn’t install SBCL before and want to use the unpacked binary distribution, copy the file run-sbcl.sh from the source directory to the toplevel directory of the binary distribution, e.g.:

$ cp sbcl/run-sbcl.sh sbcl-1.2.4--x86-64-linux/run-sbcl.sh

This script allows you to run SBCL from the builddirectory or binary distribution without having to install it, taking care of loading the correct core and setting SBCL_HOME. So, in order to build the SBCL source, run

$ sh make.sh --prefix=/home/chfin --xc-host='/path/to/unpacked/binary/distribution/run-sbcl.sh'

again replacing chfin with your username and adding your own cusomization options. Note that you should run this in a screen session and detach it since you are accessing your uberspace via SSH and watching the whole output during compilation will heavily slow down the compilation process (as described in INSTALL)

If you want, you can continue and build the documentation and run tests as described in INSTALL. To install the compiled SBCL to your uberspace now, just run:

$ sh install.sh

since the --prefix=/home/chfin already configured the install script to install the binaries to your home directory. Also, you don’t have to set SBCL_HOME anymore since it now correctly defaults to /home/chfin/lib/sbcl.


Want to comment on this article? Write me an email (GPG key: 0x12B9620D).