1

I'm trying to use auto-package-update to do what it says on the tin. As per the instructions at use-package documentation I'm using...

(use-package auto-package-update
   :ensure t
   :config
   (setq auto-package-update-delete-old-versions t
         auto-package-update-interval 2
         auto-package-update-hide-results t))
   (auto-package-update-maybe))

But when I evaluate it I get a recursive require, debugging shows.

Debugger entered--Lisp error: (error "Recursive ‘require’ for feature ‘auto-package-upda...")
  require(auto-package-update nil nil)
  eval-buffer(#<buffer  *load*-796305> nil "/home/user/.config/emacs/settings/auto-package-upd..." nil t)  ; Reading at buffer position 477
  load-with-code-conversion("/home/user/.config/emacs/settings/auto-package-upd..." "/home/user/.config/emacs/settings/auto-package-upd..." nil t)
  require(auto-package-update nil nil)
  eval-buffer(#<buffer  *load*-929330> nil "/home/user/.config/emacs/settings/auto-package-upd..." nil t)  ; Reading at buffer position 477
  load-with-code-conversion("/home/user/.config/emacs/settings/auto-package-upd..." "/home/user/.config/emacs/settings/auto-package-upd..." nil t)
  require(auto-package-update nil nil)
  eval-buffer(#<buffer  *load*-688129> nil "/home/user/.config/emacs/settings/auto-package-upd..." nil t)  ; Reading at buffer position 477
  load-with-code-conversion("/home/user/.config/emacs/settings/auto-package-upd..." "/home/user/.config/emacs/settings/auto-package-upd..." nil t)
  require(auto-package-update nil nil)
  eval-buffer(#<buffer  *load*> nil "/home/user/.config/emacs/settings/auto-package-upd..." nil t)  ; Reading at buffer position 477
  load-with-code-conversion("/home/user/.config/emacs/settings/auto-package-upd..." "/home/user/.config/emacs/settings/auto-package-upd..." nil t)
  require(auto-package-update nil nil)
  eval-region(284 477)  ; Reading at buffer position 284
  funcall-interactively(eval-region 284 477)
  call-interactively(eval-region nil nil)
  command-execute(eval-region)

Not sure where I've gone wrong?

2
  • Just out of curiosity, what file did you put your call to use-package in? Did you modify auto-package-update.el at all? Is auto-package-update.el bytecompiled (there will be a .elc file if it is)?
    – db48x
    Apr 26, 2022 at 14:26
  • The above snippet of code is in ~/.config/emacs/settings/auto-package-update.el which is loaded from ~/.config/emacs/init.el with (load "~/.config/emacs/settings/auto-package-update.el"). Not touched any of the files in auto-package-update.el and it is byte compiled.
    – slackline
    Apr 27, 2022 at 9:38

1 Answer 1

3

(require 'foo) searches each directory named in load-path for a file named foo.elc or foo.el, and loads it. Likewise, calling (use-package foo :ensure t) is the same as calling (require 'foo), and calling any function defined in the foo package will transparently autoload foo by calling (require 'foo) for you.

From your comments, I gather that you have placed the use-package form you quoted in a file named auto-package-update.el. That file is placed in the “/home/user/.config/emacs/settings/” directory, which is in your load-path. When it is loaded, it calls (require 'auto-package-update). require looks through the load-path until it finds the “/home/user/.config/emacs/settings/” directory, where there is a file named “auto-package-update.elc”, which matches the package name that it is looking for. It loads it as instructed.

You can fix this by removing “/home/user/.config/emacs/settings/” from your load-path, by giving the file a different name, or just by moving the use-package form directly into your init file, which is where most people would place it.

2
  • Thanks, spot on I had /home/user/.config/emacs/settings/in my load-path removing it and moving the code the loads auto-package-update solves the problem. Thank you very much for your explanation and time @db48x
    – slackline
    Apr 29, 2022 at 9:20
  • You’re welcome.
    – db48x
    Apr 29, 2022 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.