slotThe/vc-use-package

Cannot load package

lzhoucs opened this issue · 5 comments

I got the following error

⛔ Error (use-package): Failed to install zenburn-emacs: Package ‘zenburn-emacs’ is unavailable
⛔ Error (use-package): Cannot load zenburn-emacs

when trying to install a package with the following:

(unless (package-installed-p 'vc-use-package)
  (package-vc-install "https://github.com/slotThe/vc-use-package"))
(require 'vc-use-package)
(require 'use-package)

;; Theme
(use-package zenburn-emacs
  :vc (:fetcher "github" :repo "bbatsov/zenburn-emacs")
  :ensure
  :config (load-theme 'zenburn t))

I am on Emacs 29.0.

It does seem the package is somehow installed from github despite the error. My gut feeling is the package name is not consistent across vc-use-package, vc-package-install and use-package which caused the error even though the package is installed, it's not loaded so it's not useable.

Hi,

the issue you are running into is described here. In short: :vc always tries to install a package if it's not installed already, so passing :ensure is not necessary. Further, since :ensure gets evaluated so early, the expanded code will always look like

(progn
  (use-package-ensure-elpa 'zenburn-emacs 'nil 'nil)
  (apply #'vc-use-package--install
         '(:fetcher "https://github.com/" :repo "bbatsov/zenburn-emacs" :name zenburn-emacs))
  …)

I.e., use-package first tries to install the package with elpa and, upon failing to do that, continues with what we actually want. If you don't have use-package-always-ensure set, then just removing the :ensure should fix this.

See also: #7

Thanks for the reply.
I don't have use-package-always-ensure set and made sure it's value is nil. It seems after removing ensure the first error is gone as you imagined, but the 2nd error still exists:

⛔ Error (use-package): Cannot load zenburn-emacs

This is what I have right now:

(require 'use-package)
(unless (package-installed-p 'vc-use-package)
  (package-vc-install "https://github.com/slotThe/vc-use-package"))
(require 'vc-use-package)

(use-package zenburn-emacs
  :vc (:fetcher "github" :repo "bbatsov/zenburn-emacs")
  :config (load-theme 'zenburn t))

Ah, indeed, the package is named zenburn-emacs on GitHub, but the actual package name is zenburn-theme. Try this:

(use-package zenburn-theme
  :vc (:fetcher "github" :repo "bbatsov/zenburn-emacs")
  :config (load-theme 'zenburn t))

It worked. Thanks a lot! I didn't know the name actually matters. I thought it was just an identifier given vc-package is doing the install. If you don't mind, I wonder how to identify the package name? Is it the from the file name zenburn-theme.el, or this line: https://github.com/bbatsov/zenburn-emacs/blob/master/zenburn-theme.el#L36?

Thanks for your help. I am pretty new to elisp.

If you don't mind, I wonder how to identify the package name?

I general, Emacs packages are always named like their file names, and themes are always suffixed with -theme.

If you want to know precisely what a package will be called, just look for the provide at the end of the file. For example, for zenburn.el one can see

(provide-theme 'zenburn)

This is basically just (provide (get 'zenburn 'theme-feature)), and evaluating the inner form I get zenburn-theme.