vim / vimrc: How to find the Python plugin that's failing

572 Views Asked by At

When I start up vim, I get the following error printed:

$ vim -V9foo.log
Error detected while processing function <SNR>14_DependenciesValid:
line   12:
Traceback (most recent call last):
  File "<string>", line 6, in <module>
AttributeError: 'module' object has no attribute 'vars'
Press ENTER or type command to continue

Looking on this site, I find a few recommendations to use -V9 to print everything vim is doing. However, when I do this, I do not see the failure!

I can also use -V9foo.log to print everything it's doing to a log file (foo.log) When I do that, the startup work is all printed there, but the error is printed to the terminal. My guess thus is that the Python plugin runner does not know of the vim -V output target, or the python runtime error is printed straight to stderr.

Unfortunately, the Python error is extremely unhelpful. I cannot find a function named DependenciesValid in any of my vim plugins, and the rest of the error is all "sourced from some string, using some module, have fun finding where this is!"

I use Vundle for plug-ins, and the only reason I do that is that I want to use ensime for in-editor Scala browsing.

Commenting out ensime/ensime-vim makes the error go away, which locates the particular bundle, but doesn't get me any closer to where in the bundle the error actually happens, or why.

Here's my .vimrc:

set nocompatible
filetype off

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" Plugin 'jewes/Conque-Shell'
Plugin 'ensime/ensime-vim'
Plugin 'derekwyatt/vim-scala'

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required

" syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0

" My Stuff
set expandtab
set hidden
set ts=4
set ignorecase
set sw=4

I'm running on ubuntu 12.04 LTS (no, this is not currently upgradeable.)

$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May  4 2012 04:24:26)
Included patches: 1-429

$ uname -a
Linux (hostname) 3.19.0-32-generic #37~14.04.1 SMP Fri Nov 6 00:01:52 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
2

There are 2 best solutions below

1
On

The 14 in <SNR>14_DependenciesValid refers to the script number as listed with :scriptnames.

0
On

I finally debugged this.

First, I commented out each plugin in turn until I found which one was causing the error. It was ensime-vim.

Second, I grepped the source for that plugin for the text "vars" which is the variable name it's trying to read/write from some module.

I found a few references, and looked them all up, figuring out where they are called. It turns out, a recent change to the ensime-vim plugin did something akin to:

import vim
vim.vars['some_global_name'] = 1

The "vim" module does not contain a "vars" member in VIM 7.3, hence this fails.

Python could be more helpful about this. It says "module" does not have a member named "vars" but it doesn't tell me what the module is named. It could know. Also, Python just says that "string" was the location of the error -- it could print the line out of the string, verbatim, to help track down the problem.

Separately, Vim could be more helpful about this. It could know which .vim file contained the Python code that errored out, and it could print the file/line that defined the Python that errored out.

It turns out, neither -D, nor -V9 (which is the general recommendation on the internet before I was told about -V13 by Meninx) was all that helpful :-(