Unknown function error when opening Vim with 'git commit' command but not with 'vim' command












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:devsettings>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?










share|improve this question



























    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:devsettings>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?










    share|improve this question

























      1












      1








      1


      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:devsettings>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?










      share|improve this question














      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:devsettings>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?







      git vim command-line






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 18 '18 at 1:58









      Shaun LuttinShaun Luttin

      59.1k33227287




      59.1k33227287
























          3 Answers
          3






          active

          oldest

          votes


















          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, 'CV' . escape($HOME.'/vimfiles', ''), escape($HOME.'/.vim', '&'), 'g')
          if exists('&packpath')
          let &packpath = &runtimepath
          endif
          endif





          share|improve this answer
























          • That seems more precise than my answer. +1

            – VonC
            Nov 19 '18 at 8:33



















          1














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





          • vim-pathogen might help

          • but another alternative on Windows is to configure your editor to anything else but vim.






          share|improve this answer































            1














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



            PS> Copy-Item ~vimfiles ~.vim -Recurse





            share|improve this answer

























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53357254%2funknown-function-error-when-opening-vim-with-git-commit-command-but-not-with%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              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, 'CV' . escape($HOME.'/vimfiles', ''), escape($HOME.'/.vim', '&'), 'g')
              if exists('&packpath')
              let &packpath = &runtimepath
              endif
              endif





              share|improve this answer
























              • That seems more precise than my answer. +1

                – VonC
                Nov 19 '18 at 8:33
















              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, 'CV' . escape($HOME.'/vimfiles', ''), escape($HOME.'/.vim', '&'), 'g')
              if exists('&packpath')
              let &packpath = &runtimepath
              endif
              endif





              share|improve this answer
























              • That seems more precise than my answer. +1

                – VonC
                Nov 19 '18 at 8:33














              2












              2








              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, 'CV' . escape($HOME.'/vimfiles', ''), escape($HOME.'/.vim', '&'), 'g')
              if exists('&packpath')
              let &packpath = &runtimepath
              endif
              endif





              share|improve this answer













              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, 'CV' . escape($HOME.'/vimfiles', ''), escape($HOME.'/.vim', '&'), 'g')
              if exists('&packpath')
              let &packpath = &runtimepath
              endif
              endif






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Nov 19 '18 at 8:16









              Ingo KarkatIngo Karkat

              132k14148198




              132k14148198













              • That seems more precise than my answer. +1

                – VonC
                Nov 19 '18 at 8:33



















              • That seems more precise than my answer. +1

                – VonC
                Nov 19 '18 at 8:33

















              That seems more precise than my answer. +1

              – VonC
              Nov 19 '18 at 8:33





              That seems more precise than my answer. +1

              – VonC
              Nov 19 '18 at 8:33













              1














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





              • vim-pathogen might help

              • but another alternative on Windows is to configure your editor to anything else but vim.






              share|improve this answer




























                1














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





                • vim-pathogen might help

                • but another alternative on Windows is to configure your editor to anything else but vim.






                share|improve this answer


























                  1












                  1








                  1







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





                  • vim-pathogen might help

                  • but another alternative on Windows is to configure your editor to anything else but vim.






                  share|improve this answer













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





                  • vim-pathogen might help

                  • but another alternative on Windows is to configure your editor to anything else but vim.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 18 '18 at 2:04









                  VonCVonC

                  839k29426543196




                  839k29426543196























                      1














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



                      PS> Copy-Item ~vimfiles ~.vim -Recurse





                      share|improve this answer






























                        1














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



                        PS> Copy-Item ~vimfiles ~.vim -Recurse





                        share|improve this answer




























                          1












                          1








                          1







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



                          PS> Copy-Item ~vimfiles ~.vim -Recurse





                          share|improve this answer















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



                          PS> Copy-Item ~vimfiles ~.vim -Recurse






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Nov 19 '18 at 17:45

























                          answered Nov 18 '18 at 2:14









                          Shaun LuttinShaun Luttin

                          59.1k33227287




                          59.1k33227287






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53357254%2funknown-function-error-when-opening-vim-with-git-commit-command-but-not-with%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              這個網誌中的熱門文章

                              Xamarin.form Move up view when keyboard appear

                              Post-Redirect-Get with Spring WebFlux and Thymeleaf

                              Anylogic : not able to use stopDelay()