0

When I try to make a Git commit with Sublime using Git Bash, I get the following error:

error: cannot spawn subl: No such file or directory
error: unable to start editor 'subl'
Please supply the message using either -m or -F option.

I've tried to configure Git to use Sublime during commits by trying these different commands, without luck:

git config --global core.editor "'c:/program files/sublime text 3/subl.exe' -w"

git config --global core.editor "'C:/Program\ Files/Sublime\ Text\ 3/sublime_text.exe' -w"

git config --global core.editor "subl -n -w"

I've set up the Git Bash to open the Sublime editor, and it works perfectly fine. I've used this command to achieve that:

echo 'alias subl="C:/Program\ Files/Sublime\ Text\ 3/sublime_text.exe"' >> ~/.bashrc

I'm using Windows 10, by the way.

  • 1
    `git config core.editor "'C:\Program Files\Sublime Text 3\subl.exe' -w"` works for me. My `.gitconfig` says `editor = 'C:\\Program Files\\Sublime Text 3\\subl.exe' -w` or `editor = 'C:/Program Files/Sublime Text 3/subl.exe' -w` – both work for me. – poke Sep 13 '16 at 22:00
  • Thank you for the help! For some reason it works with backslashes, as you suggested. – Daniel Askan Filsoof Mikkelsen Sep 13 '16 at 23:44

1 Answers1

0

As the user, poke, commented on my question, the following solves the problem:

git config --global core.editor "'C:\Program Files\Sublime Text 3\subl.exe' -w"

Why the solution with backslashes over frontslashes works, is beyond me. Could be nice if someone could tell me/future readers why this solves the problem.

  • I'm no windows expert, but it's probably because they use bash slashes for [paths](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions). Like every other OS. – Novice C Sep 13 '16 at 23:47
  • The alias and also the dir command works with the frontslashes. Also, the Windows tutorials for this setup I found also use frontslashes. So, I was just wondering why it's the other way around for me – Daniel Askan Filsoof Mikkelsen Sep 13 '16 at 23:51
  • Sorry I should say unlike every other OS*. Here is a relevant stackoverflow about [windows](https://stackoverflow.com/questions/1589930/so-what-is-the-right-direction-of-the-paths-slash-or-under-windows). It seems some programs put up with windows being backwards and know to change front slashes, but perhaps git's internals don't. Just a guess, but interesting the tutorial claims it works. – Novice C Sep 13 '16 at 23:58
  • @NoviceC As I commented on the question, it also works with front slashes. In general, Windows is pretty okay with using front slashes in many situations, it’s is somewhat supported by the underlying file system APIs. – poke Sep 14 '16 at 06:40