0

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.

  1. The Magit version number doesn't have the expected format.

  2. Git does not have a version number at all.

Is this a problem? If so, what should I do to fix it?


Attempted Steps

  1. Is Git installed on my system? Opening a Terminal window and running git --version yields git version 2.10.1. In particular, Git is installed on my system.

  2. 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 running ls /usr/bin brings up a list that includes git. So the Git executables are on emacs' PATH.

  3. Are the Git executables on emacs' exec-path? Checking the value of emacs' exec-path variable by entering C-h v exec-path RET in emacs yields a string that starts with "/usr/bin", so the Git executables are on emacs' exec-path.

  4. Maybe the Git executables that the shell uses are in a different place than /usr/bin/. Try running which git from a Terminal window. I ran which 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.

  5. 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!

  6. 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's PATH and exec-path, and also the Git version is more up-to-date (it was 2.10.1 before; now it's 2.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

  • How does the output of /usr/local/bin/git --version differ from /usr/bin/git --version? – npostavs Apr 3 '17 at 14:45
  • 2
    (In case it's not clear, your code in (4) is appending to PATH/exec-path but you need to prepend.) – npostavs Apr 3 '17 at 14:46
  • 1
    @npostavs: /usr/local/bin/git --version yields git version 2.10.1, whereas /usr/bin/git --version yields xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun. – Evan Aad Apr 3 '17 at 15:30
  • 1
    tips.tutorialhorizon.com/2015/10/01/… could be relevant (or you can just keep using the git from /usr/local/bin, not clear to me what the difference is) – npostavs Apr 3 '17 at 16:00
  • 1
    By the way, the (push ...) suggested by tarsius is pretty much just a more concise way of prepending (for exec-path that is; for PATH what you have is fine). – npostavs Apr 3 '17 at 16:03
2

The Magit version number doesn't have the expected format.

All version numbers on Melpa (non-stable) are just timestamps. So this is expected. But this might be changed eventually.

Git does not have a version number at all.

That could mean that Magit is not able to find any git executable, which of course would be a big problem.

If you are actually able to use Magit, then please post the output of git version, because another possibility is that it prints something we did not expect.


Progress, at last! Hurrah! What now?

We have established that I was right all along. Your shell is configured correctly to use the git that you have installed, but that configuration does not carry over to an Emacs instance that was started by clicking on an icon. The reason for this is that Emacs does not read your shell's configuration files, which makes sense because it is a different application.

You now have to customize Emacs to use the same git executable by configuring exec-path correctly. There are multiple ways of doing that and doing it by hand is what I recommend. Based on the information you have provided I would assume that (push "/usr/local/bin" exec-path) should do the trick.

Another option would be to configure Emacs'exec-path based on your shell's configuration, even when Emacs isn't started from a shell by using the exec-path-from-shell package.

  • It turns out I didn't have git installed on my system. So I went ahead and installed it. Now when I enter git --version in a Terminal window I receive the following output: git version 2.10.1. However, when I run M-x magit-version on emacs I still get Git (unknown). – Evan Aad Apr 2 '17 at 9:27
  • Just a random guess, but you probably installed it using homebrew and can use it on the command line because your shell's $PATH has been adjusted accordingly. However you start Emacs by clicking on an icon and so environment variables that you set in your shell's init file do not apply. You have to tell Emacs where homebrew installs executable by adding an element to exec-path. – tarsius Apr 2 '17 at 12:23
  • I don't know what you mean by homebrew. I installed Git from this page. It is true that I don't invoke emacs from the command line. Where can I find out where the Git executables are? – Evan Aad Apr 2 '17 at 13:37
  • Running (getenv "PATH") in emacs yields a string that starts with /usr/bin. Opening a Terminal window and running ls /usr/bin brings up a list that includes git. – Evan Aad Apr 2 '17 at 14:22
  • (getenv "PATH") does not really matter here. Check the value of exec-path instead. – tarsius Apr 2 '17 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.