Emacs , use-package and package-refresh-contents
Asked Answered
V

1

7

In my init.el I want use "use-package" to lazily load my mode and speed up my emacs start.

I want use-package automatically download my mode from elpa/melpa/... thanks to package lib.

But it seems I need to do a (package-refresh-contents) before each time otherwise use-package raise an error.

(error "Package `deft' is not available for installation")

my conf is

(require 'use-package)
(package-refresh-contents) ; take forever at each emacs start
(use-package deft 
  :ensure t)

but (package-refresh-contents) take forever. can't we delegate the (package-refresh-contents) to use-package so it is done once ?

Vladi answered 18/6, 2014 at 8:12 Comment(0)
N
10

use-package does not provide this functionality. You could use the following instead:

(unless package-archive-contents
  (package-refresh-contents))

This will only update the package list, if it is empty, which should be sufficient to avoid your problem. You still need to manually update packages, though, with M-x list-packages and U.

Nonjoinder answered 18/6, 2014 at 8:17 Comment(1)
thks, I tried this syntax and the very first time emacs is used with this config with a fresh new .emacs.d/ I also had the error. From what you wrote this is normal, as I did not refresh package list. It seems to me that even I I had refreshed the package list the refresh occurs every time...Vladi

© 2022 - 2024 — McMap. All rights reserved.