Make Emacs & $PATH Play Nice In OS X

After setting up signing my Git commits with GPG, I realized I accidentally broke Magit!. Which is one of my favorite Emacs packages, and the best way to interact with Git.


The break was caused by a seemingly common issue for Emacs users in OS X: the PATH variable as Emacs understood it was not the PATH that terminal used. Now that my Git config was telling Git to call out to the GNUPG binary to sign the commit, and it couldn’t find it.


Typical day in the life of an engineer

This is not exactly a new issue for me. When I started writing Ruby professionally, getting Emacs to play nicely with the right binaries in OS X, so I could use Rspec within a buffer was a challenge. A challenge that always seemed to be for another day, until I broke Magit!. Funny how killing your ability to check in work can motivate you to find solutions super fast.

Must. Fix. Magit.

Must. Fix. Magit.

The fix came in the form of exec-path-from-shell, a wonderful Emacs library that solved the problem I never could, no matter how much I messed with exec-path. All I had to do was install it from MELPA, and add (exec-path-from-shell-initialize) to my config. After an eval, BOOM now every binary I could ever want to use was actually usable!! This has the added benefit of when I upgrade a system binary with Homebrew, I’ll be actually using it in Emacs!

As easy as this was, I’m sure there is some subtle thing I missed: something to do with the interaction between Homebrew, OS X, and the way I installed or set up Emacs, that I could fix without the need for a random library. But hey, who has time to figure that kind of stuff out?!

%d bloggers like this: