Skip to content

Git Commit Problem: "error: There was a problem with the editor 'vi'" #167

Closed
@codyaray

Description

@codyaray

I'm just starting to use Vundle and I'm running into an error when editing a Git message using the .vimrc setup from the README. When I try to save any git message in vim, I get the following error.

$ git commit
error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.

I've tracked this down to the initial filetype off directive (marked as required in the README). I don't understand why its causing this issue, but after commenting out the line, but this re-enabled Git commit editing in vim.

Can you shed some light on why its "required" to disable filetype detection before using vundler? And then to re-enable it (using filetype plugin indent on) later on?

FWIW, my vim version:

$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 24 2011 20:00:09)
Compiled by root@apple.com
Normal version without GUI.  Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent 
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
-conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs 
-dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path 
+find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv 
+insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent 
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape 
-mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_sysmouse 
+mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype 
+path_extra -perl +persistent_undo +postscript +printer -profile -python 
-python3 +quickfix +reltime -rightleft -ruby +scrollbind +signs +smartindent 
-sniff +startuptime +statusline -sun_workshop +syntax +tag_binary 
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
 -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo 
+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
 -xterm_clipboard -xterm_save 
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -D_FORTIFY_SOURCE=0 -Iproto -DHAVE_CONFIG_H -arch i386 -arch x86_64 -g -Os -pipe
Linking: gcc -arch i386 -arch x86_64 -o vim -lncurses

Activity

phildobbin

phildobbin commented on Apr 22, 2012

@phildobbin

I think it's to enable Vundle to bypass $VIMRUNTIME when installing & then you re-set to enable the use of filetypes.

See:

h: filetype

I'm sure our author can elucidate further :-)

gmarik

gmarik commented on Apr 30, 2012

@gmarik
Contributor

@codyaray as @phildobbin it's required to set filetype detection properly.

It's usually hard to say what causing issues for you without looking .vimrc.
Also i'd like to know what $EDITOR is set to.

Closing issue, as suspect it's just a configuration issue.
Feel free to comment if you still having issues.

sent-hil

sent-hil commented on Dec 30, 2012

@sent-hil

git config --global core.editor /usr/bin/vim solved it for me.

ruebenramirez

ruebenramirez commented on Dec 12, 2013

@ruebenramirez

git config --global core.editor $(which vim)

liyicky

liyicky commented on Feb 3, 2014

@liyicky

git config --global core.editor $(which vim) works. Very strange however because I was always using /usr/bin/vim. Whatever I guess.

coryfklein

coryfklein commented on Jun 30, 2014

@coryfklein

This worked for me too:

git config --global core.editor $(which vim)

hughgr

hughgr commented on Jul 4, 2014

@hughgr

git config --global core.editor $(which vim)

that works

cbeams

cbeams commented on Jul 16, 2014

@cbeams

I just went through this process as well:

  1. Install Vundle per instructions
  2. Try to commit something as per usual with git commit
  3. Type a commit message using $EDITOR, which is set to vi
  4. Watch commit fail with "error: There was a problem with the editor 'vi'."
  5. Search for a solution, find this blog post
  6. Try the workaround it suggests (git config --global core.editor $(which vim)), notice that it works
  7. Notice that it also works to reset $EDITOR from vi to /usr/bin/vim
  8. Feel frustrated, because no one seems to understand why this is happening
  9. Search for related issues in the Vundle GitHub repo, find this issue
  10. Remain frustrated because while everyone agrees on the workaround, there is still no actual explanation or solution
  11. Realize that this is a cycle that many more users will struggle through unless a proper fix shows up
  12. Write this comment in hopes the issue might be reopened

I'm using Vim 7.3. Thanks for Vundle. Looking forward to using it.

added a commit that references this issue on Jul 16, 2014
jdevera

jdevera commented on Jul 16, 2014

@jdevera
Contributor

@cbeams what does which vim and which vi give you?

Also, can you provide the output of:

vim --version

and

vi --version

cbeams

cbeams commented on Jul 16, 2014

@cbeams
$ vi --version | head -1
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Dec 19 2013 15:19:49)

$ vim --version | head -1
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Dec 19 2013 15:19:49)

$ ls -l $(which vi)
lrwxr-xr-x 1 root wheel 3 Feb 18 06:44 /usr/bin/vi -> vim

$ ls -l $(which vim)
-rwxr-xr-x 1 root wheel 1472736 Feb 18 06:43 /usr/bin/vim
jdevera

jdevera commented on Jul 16, 2014

@jdevera
Contributor

After reading the blog post in step 5, it gets even darker. To be honest I haven't got the slightest clue of what's going on 😒

maljub01

maljub01 commented on Aug 9, 2014

@maljub01

If the vim executable's name is vi, vim will run in vi mode. This is mentioned in the manpage under the option -v and seems to be causing this.

This gist proposes turning filetype on and then off to solve this issue. I have been using that solution for more than 8 months now without any issues (Ubuntu and OS X).

It might be a good idea to change the first two lines of the README's example .vimrc to:

set nocompatible              " be iMproved, required
filetype on                   " required for compatibility with Mac OS X, See issue #167
filetype off                  " required
cameronr

cameronr commented on Sep 16, 2014

@cameronr

i spent some time looking into this and here's what's what i found out:

first, i started with just this in my vimrc:

filetype off

and the error shows up as expected:

» /usr/bin/vi --version | head -3; /usr/bin/vi -u vimrc -c q; echo $?
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Dec 19 2013 15:19:49)
Compiled by root@apple.com
Normal version without GUI.  Features included (+) or not (-):
1

that config causes vim to load ftoff.vim (you can see what files are loaded at startup by running vim --startuptime <logfile>):

" Vim support file to switch off detection of file types
"
" Maintainer:   Bram Moolenaar <Bram@vim.org>
" Last change:  2001 Jun 11

if exists("did_load_filetypes")
  unlet did_load_filetypes
endif

" Remove all autocommands in the filetypedetect group
silent! au! filetypedetect *

if you remove silent!, you can see the error that vim is generating:

» /usr/bin/vim -u vimrc -c q
Error detected while processing /usr/share/vim/vim73/ftoff.vim:
line   11:
E216: No such group or event: filetypedetect *
Press ENTER or type command to continue

setting filetype on works around the problem because it causes the filetypedetect group to exist and no error to be generated.

so why does running as vi return a non-zero exit code when vim doesn't? i didn't spend the time to trace it down exactly, but that bug was fixed somewhere in the post 7.3 patches. if you brew install vim, which currently installs 7.4.430 the problem goes away:

» /usr/local/bin/vi --version | head -3; /usr/local/bin/vi -u vimrc -c q; echo $?
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Sep 15 2014 15:48:26)
MacOS X (unix) version
Included patches: 1-430
0

so, you can resolve this issue by setting your editor to vim (instead of vi), setting filetype on before setting it off, or upgrading your version of vim.

37 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @gmarik@cameronr@codyaray@jdevera@andreaswolf

        Issue actions

          Git Commit Problem: "error: There was a problem with the editor 'vi'" · Issue #167 · VundleVim/Vundle.vim