Could not execute editor

Solution 1:

Yesterday was just one of those days. On a lark, I decided to set the full path to vi (e.g. /usr/bin/vi) rather than just the executable. Now everything works. I have to admit that I don't get it since vi is perfectly executable on its own (my $EDITOR env variable is also set to vi), but it's working and my technical karma hasn't been so great lately so maybe I just shouldn't question the deities will...

Solution 2:

The following command

git config --global core.editor /usr/bin/vim

fixes it.

[edit]

Now I see that someone already posted it in the comments. Hope its still helpful for some blind folks like me.

Solution 3:

Unlike with the other answers here so far, for me using the absolute path to vi, and setting the git core.editor config, were not sufficient to solve the problem. (Those were already in place.)

In my situation, the problem was solved by adding the -f flag to the vi command:

git config --global core.editor '/usr/bin/vi -f'

Once this -f option is in place, I can use git rebase -i, and when I save-and-exit the commit list, the rebase proceeds as it should instead of giving the "could not execute editor" error.

The vim man page says with regard to option -f,

For the GUI version, Vim will not fork and detach from the shell it was started in. ... This option should be used when Vim is executed by a program that will wait for the edit session to finish (e.g. mail).

Well I'm not using a GUI version, that I know of. I'm running git at the bash command line in a terminal window on masOS Sierra 10.12.6. But since git rebase -i waits for the edit session to finish, I suppose that's why the -f option is necessary here. Maybe vim (without -f) tries to fork/detach from the shell for some reason I haven't been able to figure out.