Unable to install Emacs 24 from ppa:cassou/emacs

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.

Solution 1:

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?

Solution 2:

I have Emacs installed from this PPA and I checked the dependencies. Ubuntu 11.10 works with this PPA out of the box so you shouldn't have any issues. Here is the list of dependencies for the emacs-snapshot:

emacs-snapshot-bin-common (= 1:20111227-1~ppa1~oneiric1)libasound2 (>> 1.0.24.1), libc6 (>= 2.11), libcairo2 (>= 1.2.4), libdbus-1-3 (>= 1.1.1), libfontconfig1 (>= 2.8.0), libfreetype6 (>= 2.2.1), libgdk-pixbuf2.0-0 (>= 2.22.0), libgif4 (>= 4.1.4), libglib2.0-0 (>= 2.26.0), libgnutls26 (>= 2.9.11-0), libgpm2 (>= 1.20.4), libgtk-3-0 (>= 3.0.0), libice6 (>= 1:1.0.0), libjpeg62 (>= 6b1), libm17n-0 (>= 1.6.1), libmagickcore3 (>= 8:6.6.0.4), libmagickwand3 (>= 8:6.6.0.4), libncurses5 (>= 5.5-5~), libotf0 (>= 0.9.11), libpng12-0 (>= 1.2.13-4), librsvg2-2 (>= 2.14.4), libselinux1 (>= 1.32), libsm6, libtiff4, libtinfo5 (>= 5.6+20070908), libx11-6, libxft2 (>> 2.1.1), libxml2 (>= 2.7.4), libxpm4, libxrender1

Something is a muck in your dependencies. I would disable the PPA, do an apt-get update and upgrade then apt-get clean then re-enable the PPA again and try it.

Solution 3:

Just for information, on Precise Pangolin 12.04 it can be simply done with

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

and it works out-of-the-box.