Common Common Lisps in Guix
The other day, I was on #guix@libera.chat
[1] and saw someone ask about using Common Lisp on GNU/Guix. I hadn't done any work with Common Lisp in a while, but I was able to
help them solve their problem, and I wanted to publish this workaround somewhere
because it helped me to learn things about how Common Lisp and ASDF work (and how having both CLISP and SBCL installed and using ASDF might cause undefined behavior).
A Tale of Two Lisps
(require "asdf") ;; Need to load the asdf lib first.
;; Docs for this at https://asdf.common-lisp.dev/asdf/Configuration-DSL.html
;; and https://asdf.common-lisp.dev/asdf/Configuration-API.html
(asdf:initialize-source-registry
'(:source-registry
:ignore-inherited-configuration ;; This makes sure You start from a clean
;; slate.
(:tree
;; The below directory string should point to:
;; $GUIX_PROFILE/share/common-lisp/source
"/gnu/store/kdxkd5w6ycsb9lbhy4787mcq6x5sjma1-profile/share/common-lisp/source")))
;; Should be possible to add to guix home with some fancy substitution, but
;; ideally this would be a patch to the config.lisp file for clisp and installed
;; when installing that package. I still think an issue is warranted.
The main issue was faily simple: The user wanted to load a specific system using clisp that they also had installed for SBCL. The problem was that SBCL comes bundled with ASDF (as many implementations do nowadays) and therefore also installs files to override the location of the libraries the user installs for SBCL in Guix.
I was able to work around this using the script above as ~/.clisprc.lisp
in order to explicitly ignore the files created for SBCL in /etc/common-lisp
, and instead point to the actual ASDF systems in /share/common-lisp
. I also checked ECL, but it seems that implementation comes with ASDF now as well (and
so is immune to this problem.
I've opened an issue to address this in GNU Guix proper, but I am a bit stymied as to the
best course of action to take here. On the one hand, It's possible that other
issues will come up surrounding ASDF[2] in different implementations naively
following the SBCL files. They should probably not be installed profile-wide,
and instead only referenced by SBCL itself. On the other hand, Implementing a
system-wide init file for clisp is not something that the CLISP team seems to think is a good idea. Perhaps it would
be better to see about embedding this in config.lisp
, as they suggest? But then, what if a user wants to use the /etc/common-lisp
directory as intended by the original developer, for instance during
packaging?
I dunno. In a way, I'm hoping someone else chimes in[3] to discuss this. At least there is a workaround for now.
[1]: Here is the log where the conversation started. I am continually impressed with how collaborative and friendly the GNU/Guix community is.
[2]: In my research of this problem, I was unhappy to find another project out there that uses the name "ASDF", apparently something to do with scripting language version management. I wish they'd done a search beforehand, as having multiple projects with the same name introduces ambiguity and misunderstanding. There are a lot of other keys on the keyboard!
[3]: If this is You, feel free to reach out to me on IRC, Mastodon, or in the issue above! I would love to discuss pros and cons, as I truly don't know what the best course of action might be here.