I have just installed Magit from Melpa as per the instructions in the official Magit manual. I then proceeded to follow the manual's Post-Installation Tasks section, which states
After installing Magit you should verify that you are indeed using the Magit, Git, and Emacs releases you think you are using. [...]
M-x magit-version RET
should display something like
Magit 2.8.0, Git 2.10.2, Emacs 25.1.1, gnu/linux
The results of my running M-x magit-version RET
are
Magit 20170401.1145, Git (unknown), Emacs 25.1.1, darwin
This doesn't seem to match the expected output.
The Magit version number doesn't have the expected format.
Git does not have a version number at all.
Is this a problem? If so, what should I do to fix it?
Attempted Steps
Is Git installed on my system? Opening a Terminal window and running
git --version
yieldsgit version 2.10.1
. In particular, Git is installed on my system.Are the Git executables on emacs'
PATH
? Evaluating(getenv "PATH")
in emacs yields a string that starts with/usr/bin
. Opening a Terminal window and runningls /usr/bin
brings up a list that includesgit
. So the Git executables are on emacs'PATH
.Are the Git executables on emacs'
exec-path
? Checking the value of emacs'exec-path
variable by enteringC-h v exec-path RET
in emacs yields a string that starts with"/usr/bin"
, so the Git executables are on emacs'exec-path
.Maybe the Git executables that the shell uses are in a different place than
/usr/bin/
. Try runningwhich git
from a Terminal window. I ranwhich git
from a Terminal window, and indeed the result was different to/usr/bin/
, namely/usr/local/bin/
. So I added the following lines of code to my.emacs
file:(setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin/"))
(setq exec-path (append exec-path '("/usr/local/bin/")))
and restarted Emacs, but the problem remained. So, yes, the Git executables that the shell uses are indeed in a different place, but appending the correct location to the end of
PATH
/exec-path
has no effect.If appending to
PATH
/exec-path
doesn't do the trick, how about prepending? I added the following lines of code to my.emacs
file:(setenv "PATH" (concat "/usr/local/bin/:" (getenv "PATH")))
(setq exec-path (append '("/usr/local/bin/") exec-path))
and now it works!
An alternative solution: Taking a lead from a comment by npostavs below, I installed Xcode from the Apple store, restarted my computer (not sure this step was necessary; I decided to do this on my own), and ran
sudo xcodebuild -license
from a Terminal window to accept Xcode's license agreement. Now Magit works even without modifying Emac'sPATH
andexec-path
, and also the Git version is more up-to-date (it was2.10.1
before; now it's2.11.0 (Apple Git-81)
).The downside is that Xcode takes a big chunk of memory (4.53 GB), it has received many very bad reviews on the Apple store, I had to sign a license agreement with Apple, and aside from the convenience of not having to modify the Emacs path for Magit to work, I have no use for this mammoth, since I'm not an Apple developer.
Operating system: macOS Sierra, Version 10.12.4
Emacs version: 25.1.1
/usr/local/bin/git --version
differ from/usr/bin/git --version
?PATH
/exec-path
but you need to prepend.)/usr/local/bin/git --version
yieldsgit version 2.10.1
, whereas/usr/bin/git --version
yieldsxcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
./usr/local/bin
, not clear to me what the difference is)(push ...)
suggested by tarsius is pretty much just a more concise way of prepending (forexec-path
that is; forPATH
what you have is fine).