Subject: bug#45017: asdf-build-system packages have priority over user ones

From: Pierre Neidhardt <[email-masked]>
Date: Sat, 05 Dec 2020 10:17:41 +0100

Tested!

I've installed sbcl to my "common-lisp" profile along quri.
I've also cloned quri to ~/common-lisp.

Then:

--8<---------------cut here---------------start------------->8---
$ sbcl
* (asdf:locate-system :quri)
T
NIL
#P"/gnu/store/5gj1inwiqpn2fm9w384zd0grpyadx96m-sbcl-quri-0.1.0-2.b53231c/share/common-lisp/sbcl/quri/quri.asd"
NIL
NIL
NIL

;; Indeed:
* (asdf:user-source-registry-directory)
#P"/gnu/store/75qppl3a062b138fkrn324qq8f912zqh-profile/etc/common-lisp/source-registry.conf.d/"
--8<---------------cut here---------------end--------------->8---

It does not work because the sbcl package definition sets the
XDG_CONFIG_DIRS native search path which is picked by
user-source-registry-directory, which has higher priority than
default-user-source-registry.

I think the flaw is ASDF's this time:

--8<---------------cut here---------------start------------->8---
  (defun user-source-registry-directory (&key (direction :input))
    (xdg-config-pathname *source-registry-directory* direction))

;...

  (defun xdg-config-pathnames (&rest more)
    "Return a list of pathnames for application configuration.
MORE may contain specifications for a subpath relative to these directories: a
subpathname specification and keyword arguments as per RESOLVE-LOCATION \(see
also \"Configuration DSL\"\) in the ASDF manual."
    (filter-pathname-set
     `(,(xdg-config-home more)
       ,@(xdg-config-dirs more))))
--8<---------------cut here---------------end--------------->8---

So the user registry looks into XDG_CONFIG_DIRS, while really it should
just look at XDG_CONFIG_HOME.

So this patch should do (untested):

--8<---------------cut here---------------start------------->8---
- (defun user-source-registry-directory (&key (direction :input))
-   (xdg-config-pathname *source-registry-directory* direction))
+ (defun user-source-registry-directory (&key (direction :input))
+   (find-preferred-file (list (xdg-config-home *source-registry-directory*)) :direction direction))
--8<---------------cut here---------------end--------------->8---

If you confirm, then we should also report upstream I think.

Cheers!

-- 
Pierre Neidhardt
https://ambrevar.xyz/