2

I use Emacs 24.5.1 with Spacemacs and added Msys2 to the exec-path to use git.exe

When I run 'Magit-status' I get the following error:

C:/c/user/...my-folder/ isn't an existing directory.

I can see there is something weird going on with the path. There is an extra '/c/' There is a very similar error to users that use Git from Cygwin, and there is a work around to fix that by removing the extra '/cygdrive/' added to the file path. Unfortunately I haven't found anything to fix my problem.

Any ideas anyone?

Thanks

  • IMO, if you're on Windows and you don't use Cygwin, you're just asking for a headache and a half. I use Emacs on Cygwin everyday at work. – nanny May 21 '15 at 18:19
  • "added Msys2 to the exec-path to use git.exe" you're trying to use the git from Msys2? How about... don't. Use Git for Windows instead. – npostavs May 21 '15 at 20:57
  • Thanks for your suggestions. I replaced Cygwin, Mingw and Git-for-Windows for Msys2 and never looked back. It works fast and flawlessly and it has everything the other 3 have. The one an only thing that doesn't work is Magit. If this problem can't be solved then I rather prefer to live without Magit :-) – RafaelGP May 22 '15 at 9:48
  • @RafaelGP, FWIW, clearly, it does not work flawlessly, otherwise this question would not exist. – nanny May 22 '15 at 13:26
1

There is a very similar error to users that use Git from Cygwin, and there is a work around to fix that by removing the extra '/cygdrive/' added to the file path.

The existing workaround that was recently added to next (see magit issue #1318, commits "work around a cygwin path issue" and "limit cygwin path kludge to non-cygwin Emacs with cygwin Git") works for Msys2 as well. So installing the next branch will fix the problem.

Here is a copy of the relevant function for easy reference:

(defun magit-expand-git-file-name (filename &optional localname)
  (setq filename
        (if (file-name-absolute-p filename)
            (if localname
                filename
              (concat (file-remote-p default-directory) filename))
          (expand-file-name
           filename
           (and localname (file-remote-p default-directory 'localname)))))
  (if (and (eq system-type 'windows-nt) ; together with cygwin git, see #1318
           (string-match "^/\\(cygdrive/\\)?\\([a-z]\\)/\\(.*\\)" filename))
      (concat (match-string 2 filename) ":/"
              (match-string 3 filename))
    filename))
  • C:/c/?! Is this actually the default or does one have to actively misconfigure something to get there? By the way I would like to take this conversation to github.com/magit/magit/issues/1318. – tarsius May 22 '15 at 23:17
  • Oh, actually my windows machine had an older copy of magit, the existing workaround appears to work for msys2. The C:/ part of C:/c/ is added by Emacs when it tries to deal with /c/user/...my-folder returned by msys git. – npostavs May 23 '15 at 2:44
  • Thank you so much. It worked! @nanny Now Msys2 works flawlessly ;-) – RafaelGP May 23 '15 at 9:24
  • @npostavs So I don't have to change that function at all? – tarsius May 25 '15 at 19:17
  • @tarsius: yup, cygwin gives /cygdrive/c/the/repo, msys gives /c/the/repo and you already covered both. – npostavs May 25 '15 at 19:56

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.