Yesterday I became increasingly frustrated trying to download and install a library to use with my SBCL installation, a socket library (usocket and another which I can’t remember) in fact. This started me on my quest to work out how packaging works in Common Lisp. Hence my previous posts on make-package and defpackage, although these seem more for my own projects. To install other peoples libraries, asdf-install (which seems to use asdf: another system definition facility) seems to be one way to go.

To install asdf first in SBCL, we need to add the following to our .sbclrc file (I had to create this on Debian Lenny in my home folder):

(require :asdf)

since asdf is incorporated in SBCL we don’t need to download or install anything else. We need to add a local folder to the list of possible sites to install libraries in, I created a .sbcl folder with a sub-folder called asdf-registry in it, then added:

(pushnew "/home/amos/.sbcl/asdf-registry/" asdf:*central-registry* :test #'equal)

to the .sbclrc file. However when I started using asdf-install it ignored this folder and created two new folders called site and systems respectively, and a file called trusted-uids.lisp.

I then added:

(require :asdf-install)

to my .sbclrc file, again as I’m using SBCL this is all that is needed. Restarting my lisp (I closed down emacs, restarted it, and restarted slime – there is probably an easier way to do this but I’m not sure what it is) made asdf and asdf-install be available.

To use asdf-install we can install a library by using one of:

(asdf-install:install :library-name)

(asdf-install:install "")

(asdf-install:install "/path/to/locally/downloaded/file")

This should result in a query as to whether we want to install the library system-wide or just for our user. As a system-wide installation requires root privileges the second option is likely to be the required one. Then it checks for a gpg key, giving the user the option to ignore it (I must work out how to check the key). Compilation/installation follows.

Once installed we can then use the library in the current lisp session. Once we’ve restarted our lisp we need to load but not install the library which on SBCL can be done with:

(require :library-name)

To install the regex library cl-ppcre we do:

(asdf-install:install :cl-ppcre)

perform a local install, ignore the gpg key and then we’re good to go. After restarting my lisp session all I have to do is:

(require :cl-ppcre)

to be able to access the library.

Most of this post is based on the ASDF-INSTALL tutorial found here.

Which gets me to the point I wanted to be at the other day. There is another ASDF-INSTALL Tutorial which gives details of how to create packages which I’ll look at another time. There are also some instructions in the one linked to above concerning an earlier system for packaging libraries, called mk:defsystem, which I’ll also need to have a look at.