I have this in my init.el

(require 'package)
(setq package-enable-at-startup nil)

;;; Remove SC if you are not using sunrise commander and org if you like outdated packages
(setq package-archives '(("ELPA"  . "http://tromey.com/elpa/")
                         ("gnu"   . "http://elpa.gnu.org/packages/")
                         ("melpa" . "https://melpa.org/packages/")
                         ("org"   . "https://orgmode.org/elpa/")))


;;; Bootstrapping use-package
(unless (package-installed-p 'use-package)
  (package-install 'use-package))

Then this lower down inside of custom-set-variables:

    (org-ref techela tuareg haskell-mode gnuplot gnuplot-mode helm-ispell ac-ispell paredit ox-tufte auctex json org-grep iedit wgrep helm geiser slime-company company-jedi zzz-to-char rainbow-delimiters avy ivy projectile twittering-mode zerodark-theme pretty-mode flycheck-clang-analyzer flycheck-irony flycheck yasnippet company-c-headers company-shell company-irony irony irony-mode company-lua mark-multiple expand-region popup-kill-ring dmenu ido-vertical-mode ido-vertical ox-html5slide centered-window-mode htmlize ox-twbs diminish erc-hl-nicks symon rainbow-mode switch-window dashboard smex company sudo-edit emms magit org-bullets hungry-delete beacon linum-relative spaceline fancy-battery exwm use-package)))

My problem is when I clear out everything from my .emacs.d/ but the init.el which calls config.org which does lots of configurations, (i.e., I'm forcing a complete reinstall of everything package-wise) I get errors such as

Debugger entered--Lisp error: (file-missing "Cannot open load file" "No such file or directory" "ox-tufte")
  eval((require 'ox-tufte) nil)

That is, in my config.org a call is made, (require 'ox-tufte) and the error above happens. A clean startup (no existing elpa directory) should go and get ox-tufte should it not? It's included in the package-selected-packages list. My understanding is that this

;;; Bootstrapping use-package
(unless (package-installed-p 'use-package)
  (package-install 'use-package))

ensures anything listed in the package-selected-packages if not found, will be gotten from melpa etc. and setup. But then I don't see org-mode (latest from repo) specifically listed anywhere either. What am I missing here?


The code you quote only does what the comment says, i.e. "Bootstrapping use-package". If you want to install the selected packages, you have to do that explicitly by calling package-install-selected-packages.

  • So how do I say to Emacs, "I want all the package names you see in the package-selected-packages list installed if they're not already? – 147pm Mar 15 at 19:36
  • @147pm: "by calling package-install-selected-packages"? – Stefan Mar 15 at 21:34

If you're using use-package, you need not require packages. Instead, you might write:

(use-package ox-tufte
  :ensure t)

In this case, :ensure t will make sure that, if the package is not found on your system, it will search your package-archives for the package and install it to your system.

To avoid having to write :ensure t for each package you want to ensure is installed, you could (setq use-package-always-ensure t). If you set this variable to t, you still would need to use (use-package ox-tufte), you just wouldn't have to include :ensure t for every occurrence of (use-package [package-name]).

For example:

(use-package some-package
  :ensure t)

(use-package another-package
  :ensure t)

(use-package some-other-package
  :ensure t)

The previous code could be shortened with the following code:

(setq use-package-always-ensure t)

(use-package some-package)

(use-package another-package)

(use-package some-other-package)

In regard to having up-to-date packages, you could add this to your configuration:

(setq load-prefer-newer t)
  • The (setq use-package-always-ensure t) didn't seem to work, but the individual use-package... did. BTW, my other question "How is latest org-mode being installed?" is still puzzling me. My version according to org-version is Org mode version 9.1.9 (release_9.1.9-65-g5e4542 which seems out of date. So like ox-tufte how do I tell Emacs to get the latest from the org-mode repo if it's not already installed? – 147pm Mar 15 at 19:39
  • (setq use-package-always-ensure t), I believe, should be near the top of your config file, above all occurrences of use-package (except, of course, for the installation of use-package itself - which is what your bootstrap is doing). – DerpKat Mar 15 at 19:41
  • org-mode comes built-in to emacs now. I'm not sure which version of emacs that started in, however, as I'm pretty new to Emacs (I started with 26.1) – DerpKat Mar 15 at 19:42
  • Edited my answer to include keeping packages up-to-date (bottom of my answer) – DerpKat Mar 15 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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