Could not execute editor

GitVim

Git Problem Overview


I don't often have to modify multiple commit messages, but it has happened once or twice and I don't ever remember seeing this. I hope someone else has. When I git rebase -i HEAD~7, the expected list opens in vi exactly as expected. I change the pick values to edit where appropriate and then :wq.

> Could not execute editor

The core.editor setting in my global .gitconfig is vi (I've also changed it to vim in a wildly desperate move). I tried using mate, but that didn't even open the initial list properly so I changed it back.

I'm using v1.7.3 and would welcome any suggestions.

Git Solutions


Solution 1 - Git

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 - Git

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 - Git

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.

Solution 4 - Git

I had this issue, and it was caused by some part of the vcscommand plugin for vim. Starting vim with any of these commands resulted in exit code 1 ("error"):

  • vi
  • vim

But these gave me exit code 0 ("success"):

  • /usr/bin/vi
  • /usr/bin/vim
  • vi -u NONE
  • vim -u NONE

I was able to trace it back to the specific plugin by disabling ~/.vimrc and files in ~/.vim by renaming them and running vi -c q ; echo $? to quickly run vim and print the exit code.

Solution 5 - Git

For me, it was a problem with my .vimrc. Temporarily renaming that file fixed it. Followed by debugging my .vimrc. This is very similar to ignu's experience.

Solution 6 - Git

If you wanted to for whatever reason use sublime you could do something like the following in your global config file:

 git config --global core.editor "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"

Solution 7 - Git

It just took me a while to track down my problem to one of my plugins.

(specifically, it was https://github.com/ervandew/supertab)

I guess that's the downside to automatically updating all my plugins.

So best advice, disable half your vimrc and plugins. If that doesn't help, the problem's with your other half.

Solution 8 - Git

I was trying to squash commits as shown here https://www.youtube.com/watch?v=V5KrD7CmO4o. My git editor (notepad++) opened up in the rebasing step. But, in the amend commit message step, I saw the "Could not execute editor" issue. It probably happened because the git editor settings were wrong and also because I installed notepad++ in a non-standard location on my windows system. That is, 'git config core.editor' gave me notepad++ -multilnst- nosession.

To fix the issue, provide full path like this :

git config --global core.editor "'C:\CustomFolder\NPP\notepad++.exe' -multiInst -notabbar -nosession -noPlugin"

Refer : https://www.youtube.com/watch?v=YLxdkcT6H4g

Solution 9 - Git

Are you sure that /usr/bin/vim was on 1.7.3? I had the same issue because I had the backup plugin installed which is only supported in 1.7.3 and for some reason /usr/bin/vim was all of a sudden downgraded to 1.7.2, perhaps because of a major update of XCode...

Solution 10 - Git

I had this problem as well when I had already had vim open for a rebase in another terminal. I had started the rebase, got interrupted, and when I came back I tried it again from scratch in the other terminal, not realizing I was in the middle of the same rebase elsewhere. Just finishing the vim rebase session in the other terminal worked fine.

Solution 11 - Git

Oddly enough, just trying it again worked for me.

My core.editor and $EDITOR variables are not set.

Solution 12 - Git

For me, using windows: close the current terminal, and open another one(win+R, type 'cmd', then 'enter'), then it suddenly works.

Solution 13 - Git

Another option is to use nano editor.

$ whereis nano
$ git config --global core.editor path/to/nano

Fixes it.

Solution 14 - Git

VS Code solution:

git config --global core.editor "/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRob WilkersonView Question on Stackoverflow
Solution 1 - GitRob WilkersonView Answer on Stackoverflow
Solution 2 - GitLangusten GustelView Answer on Stackoverflow
Solution 3 - GitLarsHView Answer on Stackoverflow
Solution 4 - GitAnnika BackstromView Answer on Stackoverflow
Solution 5 - GitClay BridgesView Answer on Stackoverflow
Solution 6 - GitalphapilgrimView Answer on Stackoverflow
Solution 7 - GitignuView Answer on Stackoverflow
Solution 8 - GitMasterJoeView Answer on Stackoverflow
Solution 9 - GitFlovView Answer on Stackoverflow
Solution 10 - GitmmrobinsView Answer on Stackoverflow
Solution 11 - GitEben GeerView Answer on Stackoverflow
Solution 12 - Gitmiao.wangView Answer on Stackoverflow
Solution 13 - GittechkuzView Answer on Stackoverflow
Solution 14 - GitEugene BalashovView Answer on Stackoverflow