1

When I open Vim from the command line with vim, my _vimrc file runs without an error. When git commit opens vim as its editor, the following error occurs:

C:\dev\settings>git commit                                                                   
hint: Waiting for your editor to close the file... 
Error detected while processing /c/Users/me/_vimrc:
line    1:                                                                 
E117: Unknown function: pathogen#infect                                    
E15: Invalid expression: pathogen#infect()        
Press ENTER or type command to continue

Why does pathogen#infect() cause an error when git opens vim? How do we fix this?

Shaun Luttin
  • 121,071
  • 74
  • 369
  • 447

3 Answers3

2

Git ships with its own copy of Vim, and that one is built with Unix-style paths, so it looks for your plugins (like Pathogen) in ~/.vim/ instead of ~/vimfiles.

Duplicating your configuration is one way to solve it, but then you'll have to maintain both in parallel. I think a better approach is to make all Vim versions use the same configuration, by adapting the 'runtimepath' inside your ~/.vimrc. The following fragment (to be put at the top of your ~/.vimrc) will make Windows use the Unix-style paths:

" On Windows, also use ~/.vim instead of ~/vimfiles; this makes synchronization
" across (heterogeneous) systems easier.
if has('win32') || has('win64')
    let &runtimepath = substitute(&runtimepath, '\C\V' . escape($HOME.'/vimfiles', '\'), escape($HOME.'/.vim', '\&'), 'g')
    if exists('&packpath')
        let &packpath = &runtimepath
    endif
endif
Ingo Karkat
  • 161,022
  • 15
  • 231
  • 302
1

As illustrated in issue 687, that means vim, as executed in a git bash context, does not recognize pathogen.

VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755
1

Based on VonC's suggestion, my initial fix was to have both ~/.vim and ~/vimfiles.

PS> Copy-Item ~\vimfiles\ ~\.vim -Recurse
Shaun Luttin
  • 121,071
  • 74
  • 369
  • 447