Currently I am experimenting with Emacs and playing with many el files. Sometimes packages are installed from those el files or I install with a command M-x package-install. But this may cause trouble in the future if I want to replicate my emacs configuration in other computers. Is there a way to keep informed which packages installed in my system and save them in one file automatically?

4 Answers 4


Packages installed with package-install are stored under .emacs.d/elpa/ directory. You can remove a package by deleting its directory e.g. evil-20170802.1333 ;)

Check out use-package package. It provides a very useful macro:

(use-package my-favourite-package
  :ensure t)

This piece of code placed in init.el will install that package if it's not installed already, so you can simply move your init.el to another machine and the package will be installed automatically during startup.

There are some preparatory steps required for this to work (i.e. ensuring that use-package itself is installed and present), so find and follow a tutorial on use-package.

  • 2
    This is very useful, but just to be clear, this is declarative (you say what packages to install), not inquisitive. You won't be able to use use-package to replicate all the installed packages on your current system unless you find out what they are and set them up in use-package.
    – zck
    Commented Aug 28, 2017 at 15:36
M-x package-list-packages

At the end of the list are installed packages (printed in red).


The list of packages you have selected is automatically kept in the variable package-selected-packages (which is saved via Customize into your ~/.emacs).


To "replicate" your configuration on other computers ...

package-selected-packages is a variable defined in ‘package.el’.


You can use it to (re)install packages on other machines by running ‘package-install-selected-packages’.

  • Noting that (as hinted at by the quote marks, I think) you're probably not replicating your original packages. Rather, this will installing the most recent versions of those same packages.
    – phils
    Commented Jul 19, 2022 at 23:45
  • Not what I had in mind. But yeah, that's a fair point.
    – user98761
    Commented Jul 21, 2022 at 0:17

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.