0

When I try to commit using Magit, I get the following error message:

1 c:/Users/chanyoungs/AppData/Local/GitHub/PortableGit_f02737a78695063deace08e96d5042710d3e32db/cmd/git.exe … "commit" "--"

error: cannot spawn sh: No such file or directory

error: unable to start editor '"c:/Users/chanyoungs/Documents/Programming/emacs/emacs-25.1/bin/emacsclient.exe"' Please supply the message using either -m or -F option.

Here are my settings:

  • Windows 10 64bit
  • GNU Emacs 25.2.1 (x86_64-w64-mingw32) of 2017-04-24
  • Magit ver. 20170425.638
  • Git ver. 2.11.0.windows.3
  • Running Daemon

Further checks:

  • When I call git on cmd, it is called successfully
  • When I call emacsclient on cmd, in is called successfully
  • I tried running emacs with no other packages and get the same error

I searched for this error around and there are similar questions but I can't fix this with their suggestions. May be I'm not doing this right.

Any help or suggestions will be much appreciated.

4
  • What's the output from git -c "alias.X=!x() { which \"$1\" | cygpath -mf -; }; x" X sh in cmd? Does c:/Users/chanyoungs/AppData\Local\GitHub\PortableGit_f02737a78695063deace08e96d5042710d3e32db\usr\bin exist?
    – npostavs
    Commented May 2, 2017 at 14:54
  • Thanks @npostavs for the quick comment. 1. When I run git -c "alias.X=!x() { which \"$1\" | cygpath -mf -; }; x" X sh on cmd I get: error: cannot spawn sh: No such file or directory fatal: While expanding alias 'X': 'x() { which "$1" | cygpath -mf -; }; x': No such file or directory 2. Yes, I just tried to find c:/Users/chanyoungs/AppData\Local\GitHub\PortableGit_f02737a‌​78695063deace08e96d5‌​042710d3e32db\usr\bi‌​n in cmd just now and I can confirm that it exists.
    – chanyoungs
    Commented May 2, 2017 at 16:04
  • Hmm, does that .../usr/bin/ directory not contain a sh.exe file? Can you run c:/Users/chanyoungs/AppData\Local\GitHub\PortableGit_f02737a‌​‌​78695063deace08e96‌​d5‌​042710d3e32db/git-bash.exe and try which sh in that shell? (and also cygpath -m $(which sh) if that doesn't error out)
    – npostavs
    Commented May 2, 2017 at 20:13
  • 1. usr/bin/ folder does contain sh.exe 2. c:/Users/chanyoungs/AppData\Local\GitHub\PortableGit_f02737a‌​‌​‌​78695063deace08e‌​96‌​d5‌​042710d3e32d‌​b/git-bash.exe runs MINGW32 3. chanyoungs@DESKTOP-L4TTJ2L MINGW32 /c/Users/chanyoungs $ which sh gives /usr/bin/sh 4. chanyoungs@DESKTOP-L4TTJ2L MINGW32 /c/Users/chanyoungs $ cygpath -m $(which sh) gives C:/Users/chanyoungs/AppData/Local/GitHub/PortableGit_f02737a78695063deace08e96d5 042710d3e32db/usr/bin/sh.exe
    – chanyoungs
    Commented May 2, 2017 at 20:37

2 Answers 2

1

After trying various things, I realised that "sh" is not recognised in cmd so I tried to add the path to "sh.exe" in the environment variable. This seems to fix the problem.

1

I had the same problem. In my .emacs.d/init i removed my custom line:

(add-to-list 'exec-path "C:/Users/username/PortableGit/mingw64/bin") 

, so the only customized lines left were:

(add-to-list 'exec-path "C:/Users/username/PortableGit/usr/bin")
(add-to-list 'exec-path "C:/Users/username/PortableGit/bin")

There are multiple executables in the git-folder. Adding the wrong ones to exec-path does more harm than good.

Your Answer

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

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