Skip to content

Commit b6c0082

Browse files
author
Shahaf Arad
committed
Error when Vundle is loading from multiple sources.
It's quite common to see issues related to Vundle accidentally loading from several sources. Try to mitigate this issue by echoing an error.
1 parent cfd3b2d commit b6c0082

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

autoload/vundle.vim

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
" Readme: http://github.com/gmarik/Vundle.vim/blob/master/README.md
55
" Version: 0.10.2
66

7+
" Save the path from which Vundle was first loaded
8+
let vundle#vundle_path = expand('<sfile>:p:h:h')
9+
710
" Plugin Commands
811
com! -nargs=+ -bar Plugin
912
\ call vundle#config#bundle(<args>)
@@ -64,6 +67,21 @@ func! vundle#rc(...) abort
6467
if a:0 > 0
6568
let g:vundle#bundle_dir = expand(a:1, 1)
6669
endif
70+
71+
" If this function has already been called and Vim hasn't finished loading,
72+
" that is, we are not sourcing our .vimrc file later on, Vundle is probably
73+
" loading from several sources which can lead to unpredictable results.
74+
if exists('g:vundle#vundle_loading') && g:vundle#vundle_loading
75+
echoerr 'Vundle is probably loading from several sources. ' .
76+
\ 'This can lead to unpredictable results! ' .
77+
\ 'Please find and remove the duplication.'
78+
endif
79+
80+
" Set g:vundle_loading only if Vim hasn't finished loading.
81+
if !exists('g:vundle#vundle_loaded') || !g:vundle#vundle_loaded
82+
let g:vundle#vundle_loading = 1
83+
endif
84+
6785
call vundle#config#init()
6886
endf
6987

@@ -87,4 +105,12 @@ let vundle#lazy_load = 0
87105
let vundle#log = []
88106
let vundle#updated_bundles = []
89107

108+
augroup vundle
109+
au!
110+
111+
" Tell Vundle it has finished loading and Vim is up and running.
112+
au VimEnter * unlet g:vundle#vundle_loading
113+
au VimEnter * let g:vundle#vundle_loaded = 1
114+
augroup END
115+
90116
" vim: set expandtab sts=2 ts=2 sw=2 tw=78 norl:

autoload/vundle/config.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
" Verify this file is sourced from the correct Vundle path
2+
if expand('<sfile>:p:h:h:h') !=# vundle#vundle_path
3+
echoerr 'Vundle is probably loading from several sources. ' .
4+
\ 'This can lead to unpredictable results! ' .
5+
\ 'Please find and remove the duplication.'
6+
endif
7+
18
" ---------------------------------------------------------------------------
29
" Add a plugin to the runtimepath.
310
"

autoload/vundle/installer.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
" Verify this file is sourced from the correct Vundle path
2+
if expand('<sfile>:p:h:h:h') !=# vundle#vundle_path
3+
echoerr 'Vundle is probably loading from several sources. ' .
4+
\ 'This can lead to unpredictable results! ' .
5+
\ 'Please find and remove the duplication.'
6+
endif
7+
18
" ---------------------------------------------------------------------------
29
" Try to clone all new bundles given (or all bundles in g:vundle#bundles by
310
" default) to g:vundle#bundle_dir. If a:bang is 1 it will also update all

autoload/vundle/scripts.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
" Verify this file is sourced from the correct Vundle path
2+
if expand('<sfile>:p:h:h:h') !=# vundle#vundle_path
3+
echoerr 'Vundle is probably loading from several sources. ' .
4+
\ 'This can lead to unpredictable results! ' .
5+
\ 'Please find and remove the duplication.'
6+
endif
7+
18
" ---------------------------------------------------------------------------
29
" Search the database from vim-script.org for a matching plugin. If no
310
" argument is given, list all plugins. This function is used by the :Plugins

0 commit comments

Comments
 (0)