Next: , Previous: , Up: Issues with using and extending ASDF to define systems   [Contents][Index]


13.6.9 *LOAD-PATHNAME* and *LOAD-TRUENAME* have weird values, help!

Conventional Common Lisp code may use *LOAD-TRUENAME* or *LOAD-PATHNAME* to find files adjacent to source files. This will generally not work in ASDF-loaded systems. Recall that ASDF relocates the FASL files it builds, typically to a special cache directory. Thus the value of *LOAD-PATHNAME* and *LOAD-TRUENAME* at load time, when ASDF is loading your system, will typically be a pathname in that cache directory, and useless to you for finding other system components.

There are two ways to work around this problem:

  1. Use the system-relative-pathname function. This can readily be used from outside the system, but it is probably not good software engineering to require a source file of a system to know what system it is going to be part of. Contained objects should not have to know their containers.
  2. Store the pathname at compile time, so that you get the pathname of the source file, which is presumably what you want. To do this, you can capture the value of (or *compile-file-pathname* *load-truename*) (or *LOAD-PATHNAME*, if you prefer) in a macro expansion or other compile-time evaluated context.