use-package
use-package copied to clipboard
"Error (use-package): Cannot load ..." needs to be more helpful
Sometimes use-package reports an error like:
Error (use-package): Cannot load X
without giving any hint on what might be wrong, or any suggestion for what a good next step would be for the user to try. This has caused confusion more than once, e.g.
- Error (use-package): Cannot load org-plus-contrib (#597)
- ensure not working (#711)
- use-package load some packages warning (#545)
- It confused me too ;-)
I think some of these might be related too, at least in terms of the issue that org-plus-contrib
is not a valid feature symbol despite being an ELPA package name:
- package in "use-package" is not really a elisp package (#322)
- Autoloading problems with org-mode (#135)
- unload features before installing packages with :ensure · Issue #127 · jwiegley/use-package
-
No way to install
org
(#319)
There might be other packages for which this error appears, for different reasons.
Unfortunately I don't know enough to suggest what a more helpful error message would look like, but it does seem like there's room for improvement in the UX here.
Ugliest thing is that it's so even with debug-on-error
is turned on.
Any thoughts / update on this @jwiegley ? I just ran into this, too, and have no idea how to debug the issue.
I have this set in my init.el
file:
(if init-file-debug
(setq use-package-verbose t
use-package-expand-minimally nil
use-package-compute-statistics t
debug-on-error t)
(setq use-package-verbose nil
use-package-expand-minimally t))
Then I start up emacs with emacs --debug-init
.
It would be great if we could make the error message helpful by default, rather than requiring the user to copy and paste some elisp or perform some other configuration task.
For example, even if for some reason use-package
doesn't have access to a relevant error to log, at very least it should externalise some basic information about what it was doing when the failure happened - e.g., was it trying to require
that package, or compile it, or something else?
And the error message could also link to a web page / file / buffer / docstring containing some tips and tricks for ways to solve the error.
@jwiegley @skangas guys, any update on this?
"Error (use-package): Cannot load X"
without any further hints / details is very unhelpul.
Suggestion has 16 thumbs up, could you look into it?
Could you try putting this definition just after you load use-package
:
(defun use-package-require (name &optional no-require body)
(if use-package-expand-minimally
(use-package-concat
(unless no-require
(list (use-package-load-name name)))
body)
(if no-require
body
(use-package-with-elapsed-timer
(format "Loading package %s" name)
`((if (not ,(use-package-load-name name))
(display-warning 'use-package
(format "Cannot load %s" ',name)
:error)
,@body))))))
It seems that the current definition of this function tells require
to not report any errors, but I think perhaps we'd like to make them available.