MacOS – xemacs: Bad CPU type in executable

command linemacosx11xquartz

OK. So I worked around this error:

/sw/bin/xemacs: Bad CPU type in executable.

but I don't understand why what I did worked and am curious. All I did was replace /sw with what should have been an identical copy.

A little background… I've had this copy of xemacs since around 2000. I love it and it's all configured just right. Building xemacs from scratch was something I used to do way back when, but it was always such a pain that I tarred up /sw (probably originally installed using Fink) and have copied it from computer to computer since forever ago. I did this recently back in Jan '14 onto my brand new iMac running Mavericks and everything works fine. Even more recently, I upgraded from 10.7 to 10.9 on my MacBook Pro at home. I just installed xquartz and when I went to run my copy of xemacs, I got the bad CPU error.

I couldn't understand why I was having trouble since my newer iMac at work could run it no problem. After struggling with it for awhile, I tried simply tarring & copying /sw from the work iMac to my older laptop, and all of a sudden, it worked!

But /sw SHOULD be identical in every case here. They both originated from the same copy of /sw that I've been using since ~2000. Why would a fresh copy of /sw make any difference? Here's some pastes from the command line:

% /sw/bin/xemacs &
/sw/bin/xemacs: Bad CPU type in executable.
% sudo mv /sw /sw-old
% sudo mv /Users/robleach/Downloads/sw /
% /sw/bin/xemacs &
%

Home Laptop:

% uname -a
Darwin #### 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun  3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64

Work iMac:

% uname -a
Darwin #### 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64

Did the update from 10.7 to 10.9 muck around with what was in /sw? Why did the new identical copy make it work? From what I've read about this error, it seems like xemacs shouldn't even work at all since 10.7 – but it does! I use it all the time at work.

Best Answer

Running file on both executables will show you how the actual executable was compiled:

file /sw/bin/emacs

This will tell you why you're having issues running the file between different systems.

Obviously, with incompatible CPU types you'll face the error you're getting.

Rosetta was available for 10.6, but not from 10.7 onwards. Could you have been using it somehow on an older machine?