11

Is there a way to update the emacs terminal editor that comes with OS X? I could remove the binaries and install Emacs using a dmg package, but the idea was to upgrade to a newer version with some command.

3 Answers 3

12

Apple controls when / if they update emacs so most people just install a newer version of the tool and change their PATH variable so the new version is found first and runs by default.

If you like the sound of that, I recommend installing Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then install emacs:

brew install emacs

Add a link so that it'll work as emacs in the Terminal:

ln -s /usr/local/Cellar/emacs/24.5/Emacs.app /Applications

This will install the 'stable' version. As of this writing, that's 24.5:

» brew info emacs
emacs: stable 24.5 (bottled), devel 25.0-dev, HEAD
GNU Emacs text editor
https://www.gnu.org/software/emacs/

This is significantly newer (24.5.1) than the version that came with El Capitan (22.1.1):

» emacs --version
GNU Emacs 22.1.1
10
  • However doesn't this mean that typing emacs in Terminal will find the Apple supplied one first. Also you should explain why use Homebrew rather than a binary emacs and why you can't just copy that emacs over Apple's one
    – mmmmmm
    Mar 3, 2016 at 16:54
  • 2
    @Mark Because it's far more convenient than... really anything else. Testing whether it'll find the HB version first.
    – user44427
    Mar 3, 2016 at 16:58
  • After testing it, there's one more command to link it. Edited, thank you.
    – user44427
    Mar 3, 2016 at 17:01
  • surely you need more than that as you emacs in Applications is not on the path
    – mmmmmm
    Mar 3, 2016 at 17:08
  • Forgive the edit - I've made the rationale for adding a second binary to the top of this post @nbro - Short of lobbying apple to update the app, you could install this and then shove it in place of the shipping version. On 10.11 that binary is restricted by default - so you need to disable SIP and deal with weakening Apple's security model. The downside is large to messing with Apple's shipping OS. The upside to layering new tools that run instead of the shipping ones is large.
    – bmike
    Mar 3, 2016 at 17:15
1

It could be done but best not to do it. Certain directories including /usr/bin are updated and controlled by Apple so any changes there will be removed when the OS is updated, also in El Capitan and above this path is locked down by SiP and so you have to go through more hoops to chnage files there.

$ ls -lO /usr/bin/emacs
-r-xr-xr-x  1 root  wheel  restricted,compressed 35581744 Jan 13 20:12 /usr/bin/emacs

However in practice there is no need to do this. Install a new emacs in places you have access to e.g. for command line in /usr/local/bin or ~/bin - or GUI versions in /Applications or ~/Applications. /usr/local/bin is the default path so in all cases you need to edit the path to put the directory containing emacs before /usr/bin.

-3

When using the brew command the correct command is brew upgrade emacs even if you have done a brew update, the install will install Emacs 25, the older version.

Just sharing my experience.

2
  • Could you bee a bit more specific in your question as to what you are doing, what you expect and what you get. Jun 4, 2018 at 2:15
  • Verified on macOS 11.13.6: brew upgrade emacs will fail if there is no brew-installed emacs available, brew install emacs will install the most recent version (emacs-26.1_1 right now).
    – nohillside
    Jun 4, 2018 at 18:18

You must log in to answer this question.