As paprika said, Emacs uses load-path
to search for list available elisp
files (.elc
, .el
)
The load-path
is searched for the first matching package when it is being required. If multiple copies of a package are installed, then the first one will be loaded.
The distro package manager cannot install to the same source as package-install
does, since one is system-wide and the other is user-specific.
Package Sources
Built-in and Distro-Specific
Distro Package Manager
Distro package managers provide a selection of emacs packages that can be installed. In my experience these are often among the more popular/widely-used packages. Prior to the development of package.el
this was the easiest way to obtain the packages. (Easiest by virtue of just running apt-get install <package>
as opposed to using version-control or direct download.
Packages installed through the distro package manager are installed to /usr/local/share/emacs/site-lisp/
which is a default in the load-path
and will be hidden by user-specific load-path
additions.
Package.el
package.el
was first included with Emacs 24
. This version is compatible with Emacs 23
but needs to be installed manually, packages retrieved by it may or may not be compatible with Emacs 23
.
package.el
provides a browseable repository of packages for Emacs. By default only the Elpa
repository is configured, but access to MELPA and Marmelade can be added:
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
This provides access to a much larger pool of packages.
By default package.el
installs packages to ~/.emacs.d/elpa
and when (package-initialize)
is called this directory will be placed closer to the front of the load-path
, resulting in these packages taking precedence over those installed with by the distribution package manager.
Git/Bzr/hg/... + EmacsWiki
Version controlled packages can be manually retrieved from their repository through cloning. Some also provide packaged releases that can be downloaded directly.
EmacsWiki Elisp files can also be downloaded, although they are typically single files rather than directories.
Once the package is retrieved, ensure that the destination folder is on your load-path
and it will be available to use.
3rd-Party package management
These tools provide wrappers or additional functionality over the above to centralize package management. They are designed with shared configuration in mind to ensure all your machines have the same packages available.
El-Get
El-Get maintains a list of recipes that allow it to retrieve packages using package.el
, git
, emacswiki
as sources (among others). It also provides functions to ensure packages are up-to-date, manage loading (deferred or immediate), and store package-specific customization in files that are loaded automatically when the package is required
.
Cask
Cask is designed for project management in/for Emacs. It uses a cask
file to maintain a list of dependencies (other packages) required to use the package, and will download missing packages to ensure everything loads successfully.
It can be used to manage local package configurations by treating your ~/.emacs.d
as a project and calling (cask-initialize)
on startup.
straight.el
straight.el
is designed for people who want to make local changes to their packages, and possibly contribute those changes upstream. It pulls recipes from MELPA, GNU ELPA, and EmacsMirror, or allows you to specify your own. It also supports writing a revision lockfile for maximum reproducibility, among many other features.
Use-Package
Use-Package is designed primarily as an emacs configuration management tool. It will download necessary package.el
packages but does not have built-in mechanisms to access other sources. It allows for deferred loading of packages and deferred customization. This improves emacs initialization while slowing initial use of the packages (but if not using them in a given session there is only a net gain).