Skip to content

Commit

Permalink
Error when Vundle is loading from multiple sources.
Browse files Browse the repository at this point in the history
It's quite common to see issues related to Vundle accidentally loading
from several sources.
Try to mitigate this issue by echoing an error.
  • Loading branch information
Shahaf Arad committed Mar 21, 2015
1 parent 7d9b108 commit 5af0260
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
25 changes: 25 additions & 0 deletions autoload/vundle.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
" Readme: http://github.com/gmarik/Vundle.vim/blob/master/README.md
" Version: 0.10.2

" Save the path from which Vundle was first loaded
let g:vundle_path = expand('<sfile>:p:h:h')

" Plugin Commands
com! -nargs=+ -bar Plugin
\ call vundle#config#bundle(<args>)
Expand Down Expand Up @@ -61,6 +64,20 @@ endif
" :Plugin command in the vimrc. It is not possible to do this automatically
" because when loading the vimrc file no plugins where loaded yet.
func! vundle#rc(...) abort
" If this function has already been called and Vim hasn't finished loading,
" that is, we are not sourcing our .vimrc file later on, Vundle is probably
" loading from several sources which can lead to unpredictable results.
if exists('g:vundle_loading') && g:vundle_loading
echoerr 'Vundle is probably loading from several sources. ' .
\ 'This can lead to unpredictable results! ' .
\ 'Please find and remove the duplication.'
endif

" Set g:vundle_loading only if Vim hasn't finished loading.
if !exists('g:vundle_loaded') || !g:vundle_loaded
let g:vundle_loading = 1
endif

let g:bundle_dir = len(a:000) > 0 ? expand(a:1, 1) : expand('$HOME/.vim/bundle', 1)
let g:updated_bundles = []
let g:vundle_log = []
Expand All @@ -81,4 +98,12 @@ func! vundle#end(...) abort
call vundle#config#activate_bundles()
endf

augroup vundle
au!

" Tell Vundle it has finished loading and Vim is up and running.
au VimEnter * unlet g:vundle_loading
au VimEnter * let g:vundle_loaded = 1
augroup END

" vim: set expandtab sts=2 ts=2 sw=2 tw=78 norl:
7 changes: 7 additions & 0 deletions autoload/vundle/config.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
" Verify this file is sourced from the correct Vundle path
if expand('<sfile>:p:h:h:h') !=# g:vundle_path
echoerr 'Vundle is probably loading from several sources. ' .
\ 'This can lead to unpredictable results! ' .
\ 'Please find and remove the duplication.'
endif

" ---------------------------------------------------------------------------
" Add a plugin to the runtimepath.
"
Expand Down
7 changes: 7 additions & 0 deletions autoload/vundle/installer.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
" Verify this file is sourced from the correct Vundle path
if expand('<sfile>:p:h:h:h') !=# g:vundle_path
echoerr 'Vundle is probably loading from several sources. ' .
\ 'This can lead to unpredictable results! ' .
\ 'Please find and remove the duplication.'
endif

" ---------------------------------------------------------------------------
" Try to clone all new bundles given (or all bundles in g:bundles by default)
" to g:bundle_dir. If a:bang is 1 it will also update all plugins (git pull).
Expand Down
7 changes: 7 additions & 0 deletions autoload/vundle/scripts.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
" Verify this file is sourced from the correct Vundle path
if expand('<sfile>:p:h:h:h') !=# g:vundle_path
echoerr 'Vundle is probably loading from several sources. ' .
\ 'This can lead to unpredictable results! ' .
\ 'Please find and remove the duplication.'
endif

" ---------------------------------------------------------------------------
" Search the database from vim-script.org for a matching plugin. If no
" argument is given, list all plugins. This function is used by the :Plugins
Expand Down

0 comments on commit 5af0260

Please sign in to comment.