Emacs: How to Install Packages Using ELPA, MELPA

By Xah Lee. Date: . Last updated: .

Starting with emacs 24, it comes with a package system called ELPA (Emacs Lisp Package Archive). It lets you install and manage emacs packages. 〔►see Emacs 24.1 New Features (released 2012-06)

Quick Start

Add this to your emacs init:

(require 'package) ;; You might already have this line
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/"))
(when (< emacs-major-version 24)
  ;; For important compatibility libraries like cl-lib
  (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize) ;; You might already have this line

restart emacs.

emacs packages elpa screenshot
Emacs list-packages screenshot
  1. Alt+x list-packages.
  2. Find the package you want, move cursor to the line press Enter ↵.
  3. press Tab to move cursor to the “Install” button then press Enter ↵.
  4. Then, you can start to use the package.

Following are details.

Listing Available Packages

Alt+x list-packages.

Install Packages

This list is shown in package-menu-mode. In this mode, here's the most useful keys:

(For complete list of keys, Alt+x describe-modeCtrl+h m】)

For example, i want to install the clojure-mode. I type i to mark it, x to run install. Then, i got the following files in my dir, all automatically byte-compiled and loaded.


and now i can call clojure-mode, and it works right there! (no need to restart, but for some packages, you may need to turn it on or restart emacs.)

Upgrade Packages

To upgrade packages, just press 【U x】.

WARNING: package upgrade is not reliable. It is better to upgrade one package at a time. First delete the package, then install the latest.

Installed Packages Location

New packages are installed at ~/.emacs.d/elpa/.

If you want to remove all external packages, you can delete this entire directory and restart emacs. It is harmless to do so.

Packages Repositories

The source of the packages are from package servers. There are several.

Note: the emacs package system, called ELPA (aka package.el), is started by Tom Tromey. Marmalade is started by Nathan Weizenbaum. MELPA is started by Donald Ephraim Curtis (aka milkypostman) Thank you guys.

Helpful Commands and Variables

package-enable-at-startup. By default, this is t (true).

package-load-list. This determines which packages should be loaded at start-up.

Alt+x describe-function or describe-variable for details.

How to Install Emacs Package Manually

How to Install Emacs Package Manually

Emacs Customize Topic

  1. How to Set Emacs's User Interface
  2. Emacs: How to Install Packages Using ELPA, MELPA
  3. How to Install Emacs Package Manually
  4. Emacs: How to Define Keys
  5. Emacs: M-x customize Tutorial
  6. Emacs: Set File to Open in a Major Mode
  7. Organize Emacs Init File in 5 Minutes
  8. Emacs: Byte Compile Elisp Files
  9. Emacs: What's Hook?
  10. Emacs: Set Environment Variables within Emacs
Like it? Buy Xah Emacs Tutorial. Thanks.