title: Loading external packages in Common Lisp with SLIME on Debian
body: <p>I'm using SBCL 1.0.56 on Debian squeeze, with cl-swank/slime
  1:20120420-2 (Debian version number). These are all the current
  versions in unstable.</p>
  
  <p>I've been having problems with loading third party CL packages. The
  documentation for using CL on Debian (and indeed the more general CL
  usage documentation on Linux) is sketchy, contradictory, and
  out-of-date, so I'll summarize what I know. Here is where I am at.</p>
  
  <p>Debian installs binary packages (example, cl-split-sequence) in
  <code>/usr/share/common-lisp/source</code>. In the case of split-sequence, this is
  <code>/usr/share/common-lisp/source/cl-split-sequence</code>.</p>
  
  <p>The .asd file (here
  <code>/usr/share/common-lisp/source/cl-split-sequence/split-sequence.asd</code>),
  which, as I understand it, gives instructions to the CL implementation
  about version and dependencies, looks like</p>
  
  <pre><code>;;; -*- Lisp -*- mode
  (defpackage #:split-sequence-system (:use #:cl #:asdf))
  (in-package :split-sequence-system)
  
  (defsystem :split-sequence
      :version "20011114.1"
      :components ((:file "split-sequence")))
  </code></pre>
  
  <p>Now, when running slime, entering the following two lines at the REPL
  works without a problem</p>
  
  <pre><code>(require :split-sequence)
  (split-sequence:SPLIT-SEQUENCE  #\, "foo,bar")
  </code></pre>
  
  <p>The <code>(require :split-sequence)</code> invokes (I think) the builtin copy of
  ASDF inside SBCL, which presumably looks at <code>split-sequence.asd</code>. This
  is probably SBCL-specific, see <a href="http://pkg-common-lisp.alioth.debian.org/clid/clid.html/chlibs.html" rel="noreferrer">Common Lisp in Debian Manual Chapter 3 -Libraries</a>.
  It is worth noting that this page, which is as useful and detailed as
  anything I've come across, makes frequent reference to CLC (Common
  Lisp Controller), but it seems Debian is moving away from this. See
  <a href="http://article.gmane.org/gmane.linux.debian.alioth.common-lisp/2431" rel="noreferrer">Redesign of Common Lisp
  Controller</a>,
  which I don't fully understand. At any rate, none of the documented
  commands for using CLC work for me.  However, CLC is still available
  on Debian. Also, the users mailing list is dead - see <a href="http://lists.alioth.debian.org/pipermail/clc-users/" rel="noreferrer">The Clc-users
  Archives</a></p>
  
  <p>The first time <code>(require :split-sequence)</code> is invoked, it is compiled,
  and (on my system, possibly Debian-specific) the resulting <code>fasl</code> is
  placed in</p>
  
  <p><code>~/.cache/common-lisp/sbcl-1.0.56.0.debian-linux-x86/usr/share/common-lisp/source/cl-split-sequence/split-sequence.fasl</code></p>
  
  <p>I.e. the file is placed under the cache in a filesystem mirroring the
  location of the original source. The obvious question is, how does the
  system know where to look for the package? This is one thing I am not
  sure about. It looks like the search paths should be given in
  <code>/etc/common-lisp/source-registry.conf.d</code>, which is part of the ASDF
  Debian package, but the closest thing is
  <code>01-common-lisp-controller.conf</code>, which is just</p>
  
  <pre><code>(:directory  #p"/usr/share/common-lisp/systems/")
  </code></pre>
  
  <p>Maybe this is hard-wired somewhere, but I'd like to know.</p>
  
  <p>Anyway, once this ASDF file is in the cache, it is not compiled again,
  but the REPL doesn't see it after slime starts up unless one does
  <code>require</code> again.</p>
  
  <p>Now, if I put the lines</p>
  
  <pre><code>(require :split-sequence)
  (split-sequence:SPLIT-SEQUENCE  #\, "foo,bar")
  </code></pre>
  
  <p>In a file, say <code>seq.lisp</code>, and load it into the REPL with C-c C-k, I get
  an error and traceback, starting with</p>
  
  <pre><code>The name "SPLIT-SEQUENCE" does not designate any package.
     [Condition of type SB-KERNEL:SIMPLE-PACKAGE-ERROR]
  </code></pre>
  
  <p>so I conclude that the package has not been loaded correctly. I tried variations like</p>
  
  <pre><code>(asdf:oos 'asdf:load-op :split-sequence)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>(asdf:load-system :split-sequence)
  </code></pre>
  
  <p>but no dice. Weirdly, suppose we just have the line</p>
  
  <pre><code>(require :split-sequence)
  </code></pre>
  
  <p>in a file - call this <code>require.lisp</code> for clarity.  Then loading
  <code>require.lisp</code> doesn't give an error, and then typing</p>
  
  <pre><code>(split-sequence:SPLIT-SEQUENCE  #\, "foo,bar")
  </code></pre>
  
  <p>at the REPL works! However, without loading <code>require.lisp</code>, typing the
  preceding line doesn't work at the REPL.</p>
  
  <p>So, in conclusion, how can one successfully load a package in a
  script?  I'd also be interested in the issue mentioned above, about
  how ASDF is finding the <code>/usr/share/common-lisp/source/</code> location, but
  that is more a side issue.</p>