8

I installed auctex from Ubuntu's software center, and then I installed a newer version of auctex from emacs.

I then uninstalled the auctex installed by Ubuntu's software center. I found that it didn't uninstall the one I installed from emacs.

How does emacs manage its packages?

Are there no interference between emacs and Ubuntu in managing installation and uninstallation of emacs packages?

If I am correct, a few years ago, there was no way to install packages within emacs?

Thanks.

  • 2
    IMO, this question is too broad for SE Q&A. Better to read the Emacs doc, and then post here a specific question about a specific part of package management that is unclear to you. We should not be reproducing Emacs doc here. And if there is something important that is missing from the Emacs doc then you should file a bug report / enhancement request: M-x report-emacs-bug. People responding to such a question here would be better off contributing to the Emacs docs, if the info is missing. IMHO. – Drew Sep 30 '14 at 22:38
  • 2
    Tim: Just in case there's any confusion, an Emacs "package" and an Ubuntu/Debian "package" are entirely unrelated things. Any Emacs-related Debian package has no connection whatsoever to the package.el package manager built into Emacs 24. – phils Oct 1 '14 at 5:14
  • @Tim, Don't forget to accept ananswer, or let us know if the answers are not satisfactory. – Malabarba Oct 15 '14 at 16:27
  • @Drew The question is more about the interaction between Ubuntu and Emacs packages though, so wouldn't be covered in the Emacs docs. And the answers also discuss third-party packages which the docs don't cover, so this is probably the best place to ask such things. – Brian Burns Jan 4 '15 at 12:49
10

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).

  • elpakit is also available, it performs a similar job to cask but without the non-elisp bits. – nic ferrier Oct 19 '14 at 20:08
  • @nicferrier Could you elaborate how to use it for package management? (I can see how to use it for existing packages, but Cask also allows for arbitrary sources to be added if I read it correctly) – Jonathan Leech-Pepin Oct 19 '14 at 22:11
  • well elpakit mainly lets you do two things: build repositories on your disc as packages (it also makes package archives from collections of those) and to make packages that depend on other packages automatically. M-x elpakit-package-list-buf make a buffer with a list of your elpa packages in it which you can then use to make another package that depends on selected elpa packages. – nic ferrier Oct 20 '14 at 10:43
  • I think the packages installed through the distro package manager go into /usr/share/emacs/site-lisp, not /usr/local/share... since the local dirs are meant for non distro installs. – JeanPierre Jul 13 '17 at 7:52
9

Emacs uses the load-path, which is essentially a list of directories it should search for Lisp files. If a package is available in the load-path then it is installed.

There is no interface between the Debian/Ubuntu package manager and the Emacs package manager (package.el). The former installs Emacs packages in a system-wide fashion (available to every user of the computer) while the latter installs a package by default under your home directory. Theoretically you can use both sources to install packages. However, I would advise against this practice: You might experience some issues when you install the same package from both sources.

The list of Emacs packages you can install through the Debian/Ubuntu package manager is much more limited when compared to ELPA/MELPA/..., because each package has to be prepared specifically for Debian/Ubuntu. In other words: package on ELPA != package in Debian.

  • When he asked about a few years ago I think he was talking about Elpa – Malabarba Sep 28 '14 at 22:31
  • @Malabarba: Indeed, I misunderstood. I removed the irrelevant sentence. – paprika Sep 28 '14 at 23:18
  • This answer is true for other distro package managers as well such as yum (Fedora), pacman(Arch) etc. – Vamsi Sep 28 '14 at 23:39
  • And you're missing marmalade-repo from the list. The original non-GNU repository. – nic ferrier Oct 19 '14 at 20:07

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.