Ubuntu – Unable to install Emacs 24 from ppa:cassou/emacs

11.10emacsppa

I followed the following instructions to install Emacs 24 on my machine (borrowed from: http://www.mikeyboldt.com/2011/11/30/install-emacs-24-in-ubuntu/):

sudo add-apt-repository ppa:cassou/emacs
sudo apt-get update
sudo apt-get install emacs-snapshot

But I get the following errors:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
emacs-snapshot : Depends: libgnutls26 (>= 2.12.6.1-0) but 2.10.5-1ubuntu3 is to be installed
Depends: libmagickcore4 (>= 8:6.6.9.7) but it is not installable
Depends: libmagickwand4 (>= 8:6.6.9.7) but it is not installable
E: Unable to correct problems, you have held broken packages.

Best Answer

I had the same error yesterday. I tried installing every emacs package in the repository, and when that didn't work, it occurred to me that maybe conflicts were the problem. Since I didn't need emacs23 if emacs-snapshot would work, I did the following:

Uninstall All Emacs Packages

Before proceeding, have a look at what emacs packages might be installed by issuing `sudo apt-cache search emacs'. If you can sacrifice everything in the output, go ahead with the following suggestion.

sudo apt-get remove `apt-cache search emacs | awk '{print $1}'` --purge

If something else shows up in the output that you wish to keep, a quick way to get rid of the things you don't want is to redirect the output of the command to a file, edit that file, and then use the contents of that file for arguments to apt-get remove.

  1. sudo apt-cache search emacs > remove.txt
  2. Edit remove.txt by deleting the lines of packages you wish to keep. The goal here is to get rid of anything emacs-related, so leave those packages in the file.
  3. sudo cat remove.txt | xargs apt-get remove --purge

You may get some errors here since emacs-snapshot failed to install correctly. If you do, try uninstalling those packages manually by first force installing the broken packages and then remove-purging them.

sudo apt-get -f install # don't list packages here
sudo apt-get remove emacs-snapshot --purge

It's probably also a good idea to autoclean and autoremove.

sudo apt-get autoclean
sudo apt-get autoremove

Install Emacs 24

sudo apt-get install emacs-snapshot

This assumes that you have the PPA added correctly (I'm using the cassou PPA as well). Everything seems to work nicely now!

Try aptitude

Since originally writing this answer I've moved on the using aptitude to manage my packages on the command line. I don't like the graphical interface (ncurses) you get from issuing sudo aptitude, so I only use it when I need to resolve dependencies/conflicts leftover from experimenting with different desktop environments. Most of the time, I simply use it as a drop-in replacement for apt-get, as in sudo aptitude install [package].

Related: Is aptitude still considered superior to apt-get?

Related Question