[ACCEPTED]-Could not execute editor-vim

Accepted answer
Score: 187

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

Score: 162

The following command

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

fixes it.

[edit]

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

Score: 7

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

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

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

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

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

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

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

Score: 6

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

  • vi
  • vim

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

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

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

Score: 3

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

Score: 3

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

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

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

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

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

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

Score: 1

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

To fix the issue, provide 1 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

Score: 0

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

Score: 0

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

Score: 0

Oddly enough, just trying it again worked 2 for me.

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

Score: 0

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

Score: 0

Another option is to use nano editor.

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

Fixes 1 it.

Score: 0

VS Code solution:

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

0

More Related questions