UP | HOME

Load ASDF Systems from the CWD

add the current working directory to the ASDF registry

My workflow when it comes to development on lisp libraries, is to change into the project the launch a SLIME shell. This works great but how do I load systems from that project?

Well I used to use a snippet like this.

(push (truename (make-pathname :directory (sb-posix:getcwd)))
      asdf:*central-registry*)

This is not what most people seem to be doing, instead they are using a local projects directory to host any local projects for example in roswell that directory is .roswell/local-projects. But often I find that I might want to try and extend a system, or to hack on it, so I like to have local copies.

I had experimented with creating symlinks into the local project dir, but in the end it has always left me unsatusfied.

While looking into better ways to do this I found that the asdf:*central-registry* is not recommended as the way to add paths to the load order. Instead it's recomeneded that you add configuration files to .config/common-lisp/source-registry.conf.d that will state where to find systems.

It does have one limitation though, you can't exceute anything, the files are loaded and treated as data.

But through some experimentation I found that read macros are honored, so doing something like this will always add the current working directory of any lisp to the load path. Just insert it into .config/common-lisp/source-registry.conf.d/pwd.conf.

;;; -*- Mode: Lisp; Syntax: COMMON-LISP; Base: 10 -*-
(:directory #.(uiop/os:getcwd))

Copyright © 2019-2023 Russell Sim (rsl@simopolis.xyz).

Author: Russell Sim (Mastodon | SourceHut | Github) Date: 2023-01-04 Wed 00:00 Emacs 29.0.91 (Org mode 9.6.5)