Emacs in MacOS X 10.5 Leopard

By: on November 27, 2007

If you’ve upgraded to Leopard, and you’re an Emacs user, you may have found that typing emacs in a term no longer works — you get “Fatal malloc_jumpstart() error”. This will be the case if you’re using something like Fink or Darwin Ports, but it may also be the case if the upgrade didn’t quite work out.

The builds in Fink and Darwin Ports are currently broken; but otherwise, you have a few options to get Emacs back:

Use the Emacs that comes with Leopard. All this solution involves is making sure that any custom binary isn’t on the path — remove or move /sw/bin/emacs or /opt/local/bin/emacs (or possibly even /usr/local/bin/emacs) and make sure /usr/bin/emacs is the one installed with Leopard — /usr/bin/emacs --version should tell you the version is “22.1.1”.

The problem with the Emacs shipped with Leopard is that it’s built with no X support (or Carbon, for that matter)(although it does have Carbon support — see below).

Use Aquamacs. Aquamacs has precompiled binaries which work with Leopard. But, beware, it is quite different from Emacs in some ways — if you used Emacs before you used MacOS X, you probably won’t like it.

Compile your own Emacs. This is what I did. The stock 22.1 source distribution won’t build in Leopard; it gives up the ghost with a message “Assertion failed: (filesize <= ranges->size)”. However there is an unofficial patch, which worked for me. I’m going to keep my custom emacs until fink or ports catches up.

In summary (adapted slightly from here):

curl -O http://ftp.gnu.org/pub/gnu/emacs/emacs-22.1.tar.gz
tar xvzf emacs-22.1.tar.gz
cd emacs-22.1
curl -O http://ephemera.continuation.org/patches/emacs-leopard-unexec.patch
patch -p0 < emacs-leopard-unexec.patch
./configure --without-carbon --with-x --prefix=/usr/local
make
sudo make install

I put the result in /usr/local and made sure /usr/local/bin was on my path before any of the other possibilities, while I wait for Fink or Ports to catch up.

UPDATE: Thanks to masklinn's comment below, I can present another option which I'd overlooked:

Use carbonised Emacs. If you want to run Emacs in its own window, but don't want X11, there is a ready-made .app wrapper in the source distribution. The disk image, which masklinn suggests, has patches and some very useful bundled Elisp packages, like nxml-mode.

You can also use the emacs distributed with Leopard with the .app wrapper, as jfb points out (see the second comment below); or, compile your own carbonised Emacs, similar to what I did above: change the configure invocation

./configure --with-carbon --without-x
make
cp -R mac/Emacs.app ./
cp src/emacs Emacs.app/Contents/MacOS/
sudo mv Emacs.app /Applications/

Either way gives you an Emacs that behaves like a MacOSX app and doesn't need X11 to run.

FacebookTwitterGoogle+

14 Comments

  1. masklinn says:

    You can also use Carbon Emacs (http://homepage.mac.com/zenitani/emacs-e.html), it’s a “normal” emacs (as opposed to Aquamacs) and I’ve had no problem with it on leopard.

    I strongly suggest that you try it, it doesn’t have the polished aqua interface of Aquamacs but other than that it works perfectly.

  2. jfb says:

    Actually, /usr/bin/emacs IS built with Carbon support; all you have to do is download the Emacs.app wrapper from the Emacs CVS repository, and then:

    % ln /usr/bin/emacs Emacs.app/Contents/MacOS/Emacs

    Presto! Carbonized Emacs on Leopard.

  3. prestowk says:

    My choice is the NeXT/OpenStep (= Cocoa) Emacs 23 port available at http://emacs-app.sf.net/. This port is based on the GNU Emacs unicode-2-branch, and is an alternative to the Carbon Emacs 22 port. The Cocoa port might become the official GNU Emacs Mac port in the future, although that does not seem to have been decided yet.

  4. Bill Greene says:

    if you used Emacs before you used MacOS X, you probably won’t like [Aquamacs].

    Personally, I have been using Emacs since 1986, and I like Aquamacs a lot. I will grant that some Emacs veterans may want to specify for Aquamacs, as I do, the more familiar behavior:

    (one-buffer-one-frame-mode 0)

    And they may want to specify a Meta key other than the default Alt (see http://www.emacswiki.org/cgi-bin/wiki/AquamacsFAQ#toc8). (I personally am using the default, but reserve the right to change my mind.)

    But Emacs is a customizable editor, remember. :-)

  5. Catherine says:

    I had the problem described above, i.e. I’ve just upgraded to Mac OS X 10.5 and when I try to use emacs I get the following error:

    Fatal malloc_jumpstart() error

    I tried to delete /sw/bin/emacs, as suggested above under “Use the emacs that comes with Leopard”, but it said “Permission denied”.

    I then did:
    /usr/bin/emacs –version
    and got:
    GNU Emacs 22.1.1
    Copyright (C) 2007 Free Software Foundation, Inc.
    GNU Emacs comes with ABSOLUTELY NO WARRANTY.
    You may redistribute copies of Emacs
    under the terms of the GNU General Public License.
    For more information about these matters, see the file named COPYING.

    So it would seem that it is the correct version (22.1.1, right?), but it’s still not working. Any ideas?

  6. Catherine says:

    NB if I do
    emacs –version

    I get
    GNU Emacs 21.2.1
    Copyright (C) 2001 Free Software Foundation, Inc.
    GNU Emacs comes with ABSOLUTELY NO WARRANTY.
    You may redistribute copies of Emacs
    under the terms of the GNU General Public License.
    For more information about these matters, see the file named COPYING.

    So, a different version..

  7. mikeb says:

    Catherine,

    /usr/bin/emacs will almost certainly be the one that came with Leopard. But it looks like another one is first in your path.

    You can find out what just ‘emacs’ gets you by typing “which emacs” — probably the result will be /usr/local/emacs (built locally or maybe from Darwin Ports) or /sw/bin/emacs (from Fink). “echo $PATH” will tell you where and in which order the shell is looking.

    You’ll need to be superuser to remove things under /sw/bin:
    “sudo rm /sw/bin/emacs”.

    HTH,
    mikeb

  8. Peter Szolovits says:

    I’m confused by this thread. On my 10.5.2 system, the only emacs installation I see in the places mentioned here is /usr/bin/emacs, which tells me it’s version 21.2.1. I do use Aquamacs (and like it, despite having been an emacs user since the first version), but would like a simple emacs that can run in a terminal window for quick edits.

  9. Heiko says:

    Thanks man, I tried option “Compile your own Emacs” and was there in 5 min. This was very helpful for me!

  10. Eric says:

    Hi when I try the ocnfigure command I get:

    /Users/ericg/emacs-22.1&gt;./configure --without-carbon --with-x --prefix=/usr/local
    checking build system type... i386-apple-darwin9.2.2
    checking host system type... i386-apple-darwin9.2.2
    checking for gcc... gcc
    checking for C compiler default output file name...
    configure: error: C compiler cannot create executables
    See `config.log' for more details.

    Any help is appreciated !

    Eric

  11. MG says:

    I followed your steps to apply the patch, and it worked perfectly, except now my version of EMACS is the GUI version (running in X11).

    Do you know if it’s possible to use the same install to run the non-graphical flavor (the default on 10.4 at least)?

  12. MG says:

    For now I’m just going to install the MacPorts version.

  13. tonyg says:

    @MG: Does “emacs -nw” work? It should run in your terminal, without opening a new X window. Alternatively, unset DISPLAY (or set it to the empty string) before running emacs, perhaps.

  14. mikeb says:

    General caveat: things may have moved on since last November. In particular, it sounds like MacPorts (used to be “DarwinPorts”) at least has caught up.

    @Eric:
    Take a look in config.log to see what the precise problem is (likely to be a library it can’t find). Reinstalling the XCode distribution may help.

    Unless you specifically want to use X, you could Carbonise the emacs that is distributed with Leopard, or use the disk image.

    @Peter:
    /usr/bin/emacs, if it’s indeed the one distributed with Leopard, will run in a term. You can also force this with “emacs -nw”, as Tony mentioned.

Post a comment

Your email address will not be published.

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>