6

I have read that using use-package, one can manage installation of the packages from the init.el file. Is there any specific command for that ?

Background: I'm planning to port my existing init.el to use use-package. But I'm not able to find any documentation of how to install all the dependencies of my init.el file. I can see in the documentation that they have the :ensure keyword which will install the software if it isn't present already, but it raises few other questions:

1) How to make use-package understand that you have to install this package from MELPA and that from marmalade.

2) Is there a single command for installing all the packages from init.el.

2 Answers 2

12

Emacs' built-in package manager, and thus use-package as well, automatically installs the latest version a package, across all repositories. Normally, that means packages are installed from MELPA, because MELPA serves the highest version numbers.

However, from Emacs 24.4 onwards you can pin individual packages to specific archives with the :pin keyword:

(use-package projectile
  :ensure t
  :pin marmalade)

This tells use-package to install Projectile from Marmalade, provided that you have marmalade in your package-archives:

(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages"))

Note, though, that if you have Projectile installed prior to these settings, use-package will not automatically reinstall Projectile from Marmalade.

You can install all packages declared in your init file by simply re-evaluating your init file, either by restarting Emacs, or with M-x eval-buffer in a buffer with your init file, or with M-: (load user-init-file). use-package will then automatically install all missing packages.

2
  • Also to note that pinning will work only in emacs 24.4 onwards. Commented Feb 26, 2015 at 12:08
  • @kaushalmodi Thanks. Updated the answer accordingly.
    – user227
    Commented Feb 26, 2015 at 12:13
2

1) How to make use-package understand that you have to install this package from MELPA and that from marmalade

Thats determined by your setting for package-archives. This defaults to the GNU repository only. I add MELPA to it.

(require 'package)
(add-to-list 'package-archives '("melpa" .  "http://melpa.org/packages/") 'APPEND)
(package-initialize)

2) Is there a single command for installing all the packages from init.el.

Just restart Emacs. It will install all packages requested by use-package

1
  • Sorry I didn't read your question correctly. lunaryorn has the right answer with ':pin'.
    – Colin Bell
    Commented Feb 27, 2015 at 3:00

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.