I am currently working on a remote using Lmod for handling modules. I want to use Magit with the repositories on this remote, but the default system version of Git is 1.x. However, Git 2.18 is available on the cluster as a module (accessible at /software/git-2.18/bin/git), which I already called in my .bashrc through module add git-2.18.

When Magit connects to the remote through Tramp, though, it still calls Git 1.x, resulting in

Error (magit): Magit requires Git >= 2.2.0, but on /ssh:myremote: the version is 1.x.x.
If multiple Git versions are installed on the host, then the
problem might be that TRAMP uses the wrong executable.
First check the value of `magit-git-executable'.  Its value is
used when running git locally as well as when running it on a
remote host.  The default value is "git", except on Windows
where an absolute path is used for performance reasons.
If the value already is just "git" but TRAMP never-the-less
doesn't use the correct executable, then consult the info node
`(tramp)Remote programs'.

(The default value was Git already)

I currently fixed this temporarily by setting the custom variable magit-remote-git-executable to "/software/git-2.18/bin/git", but it makes it impossible to work on other remotes without modifying the variable manually each time.

Would you have any thoughts on how to fix this on either end?


  • This answer helped me solve the issue.
    – zola
    Jun 25, 2022 at 13:51
  • This answer helped me solve the issue.
    – zola
    Jun 25, 2022 at 13:53

1 Answer 1


How about using C-hig (emacs)Connection Variables to conditionally set magit-remote-git-executable on the hosts where you want that?

You could alternatively try setting tramp-remote-path such that your preferred location (if it exists) will be examined first when looking for git; but you may get better performance with magit-remote-git-executable set explicitly, so I'd try that first.

  • So something like (connection-local-set-profile-variables 'myremote-config '((shell-file-name . "/bin/bash") (shell-command-switch . "-c module add git-2.18"))) (connection-local-set-profiles '(:application tramp :machine "myremote") 'myremote-config) right? Aug 5, 2021 at 13:50
  • Tested it as above but it did not work Aug 5, 2021 at 14:26
  • I've no clue about the "module" command. My suggestion was to set magit-remote-git-executable.
    – phils
    Aug 5, 2021 at 21:54
  • Oh I think I got what you mean, sorry I got bamboozled by the docs. More like this? (connection-local-set-profile-variables 'myremote-config '((shell-file-name . "/bin/bash") (magit-remote-git-executable . "/software/git-2.18/bin/git"))) (connection-local-set-profiles '(:application tramp :machine "myremote") 'myremote-config) Aug 6, 2021 at 16:05
  • That's the idea. Seems like it doesn't affect dired buffers, but I can see that it works for file-visiting buffers.
    – phils
    Aug 7, 2021 at 4:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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