radian-software / radian

🍉 Dotfiles that marry elegance and practicality.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to override the recipe for a package in Radian

haji-ali opened this issue · comments

What is the correct way to change the version of a package that Radian uses?
I want to install my own version of auctex, but then I get

Warning (straight): Two different recipes given for "auctex" (:pre-build cannot be both nil and (("./autogen.sh") ("./configure" "--without-texmf-dir" "--with-lispdir=.") ("make")))

And the version that is cloned in straight/repos is not the one I specify in my init.local.el.

This is not unexpected since Radian has a (straight-use-package auctex) which clones the default version and whose recipe is different from mine. So how do I override this configuration?

Is forking Radian my only option?

You can use the variable straight-recipe-overrides, which can be set on radian-before-straight-hook, e.g.

(radian-local-on-hook before-straight
  (push '(auctex ... your custom recipe ...)
        straight-recipe-overrides))

Thanks @raxod502. I don't know why but this method doesn't seem to work. Here's what I did

(radian-local-on-hook
 before-straight
 (push '(auctex
         :host github
         :depth full
         :repo "haji-ali/auctex"
         :branch "tex-build-only"
         :pre-build
         (("./autogen.sh")
          ("./configure" "--without-texmf-dir" "--with-lispdir=.") ;; Use local directory
          ("make"))
         :files ("*" (:exclude ".git")))
       straight-recipe-overrides)
 )

I then tried running emacs (with Radian), but the repo in straight/repos was not updated. I then deleted the auctex directories in straight/build and straight/repos and restarted emacs, but the emacs-straight repo of auctex was still cloned instead of my clone. I then tried adding the following (in addition to the above before-straight hook):

(radian-local-on-hook
 after-init

 (setq debug-on-error t)
 (use-package auctex
  :straight '(:host github
              :depth full
              :repo "haji-ali/auctex"
              :branch "tex-build-only"
              :pre-build
              (("./autogen.sh")
               ("./configure" "--without-texmf-dir" "--with-lispdir=.") ;; Use local directory
               ("make"))
              :files ("*" (:exclude ".git"))
              )))

(Even tried deleting the auctex directories from build and repos). But then I got an error

Debugger entered--Lisp error: (file-error "Searching for program" "Permission denied" "/home/abdo/.config/emacs-dist/radian/.emacs.d/stra...")

Inspecting straight/repos/auctex I still find https://github.com/emacs-straight/auctex.git as the repo remote.
Evidently the :pre-build arguments were overridden but not the repo!

the repo in straight/repos was not updated

Yes, that's expected, as you need to run M-x straight-normalize-package to update the repository configuration on disk. If it were done automatically at every startup, it would be very slow.

Evidently the :pre-build arguments were overridden but not the repo

Oh, sorry about that, I gave you incorrect code. The docstring of straight-recipe-overrides explains the correct format. I think this is what you actually want:

[this was wrong, removed]

Actually, wait, that's not quite right. One moment.

This is what you want:

(radian-local-on-hook
    before-straight
  (setq
   straight-recipe-overrides
   '((radian-local . ((auctex
                       :host github
                       :depth full
                       :repo "haji-ali/auctex"
                       :branch "tex-build-only"
                       :pre-build
                       (("./autogen.sh")
                        ("./configure" "--without-texmf-dir" "--with-lispdir=.") ;; Use local directory
                        ("make"))
                       :files ("*" (:exclude ".git"))))))))

Yes, that's expected, as you need to run M-x straight-normalize-package to update the repository configuration on disk. If it were done automatically at every startup, it would be very slow.

Ah OK. Still, I was running into a chicken-and-egg problem where simply overriding the recipe in straight-recipe-overrides was not enough to trigger the re-cloning when calling straight-normalize-package. Restarting Emacs on the hand gives an error because the build commands were being attempted on the old repo (before I had a chance to call straight-normalize-package). In any case, deleting the repo and restarting was enough to get this sorted.

Regarding AUCTeX. I am not sure if this is Radian related or straight related. But now even though my recipe works (as in the correct repo is called and the build commands are executed), the auctex packages themselves are not being loaded correctly. Thinking more about it, I am not 100% sure how straight loads auctex. The (non-standard) method that auctex uses is to load the files auctex.el and preview.el which is not part of my recipe or the original straight recipe. If I load these files manually everything works, but I am wondering what's the straight Way (tm) to do this.

Addendum to the above---there's a special straight-override-recipe function specifically designed for this purpose, which eliminates the need for the alist and all that: you can just pass your desired AUCTeX recipe as an argument to straight-override-recipe, and it takes care of things.

I was running into a chicken-and-egg problem

Yeah, unfortunately this is a limitation of straight.el at present. There really should be a way (e.g., environment variable or command-line option) to tell straight.el that it should re-normalize all repositories (or a specific one) during the startup process, as the packages are registered. That feature is needed for exactly this case, and it has bothered me in the past.

I don't see any technical reason why this feature would be difficult to add to straight.el; it's just that neither I nor anyone else has gotten around to it.

Regarding AUCTeX

I am not an expert on AUCTeX. What I can tell you, though, is that straight.el doesn't do anything special at all to load a package. All it does is add the package to the load-path. It doesn't explicitly load any files. So, if the package needs to be loaded in order to work, you have to do that manually (or by use-package, with :demand t et al.).

Typically packages should be loaded automatically when you enable the relevant major mode or invoke the relevant command, via the autoload system. If that's not the case, there's not a ton that the package manager can do (with its present design, anyway).