Hi there!
I'm having an issue with running mri and rubocop checkers somewhat recently. It used to work fine and would check automatically on file save, but now it does not. Here is the output of SyntasticInfo
Syntastic version: 3.6.0-74 (Vim 704, Darwin)
Info for filetype: ruby
Global mode: active
Filetype ruby is active
The current file will be checked automatically
Available checkers: mri rubocop
Currently enabled checkers: mri rubocop
And here is the debug output of a normal file save:
"app/models/application_document.rb" 27L, 789C written
syntastic: 302.556048: &shell = 'bash', &shellcmdflag = '-c', &shellpipe = '2>&1| tee', &shellquote = '', &shellredir = '>%s 2>&1', &shellslash = 0, &shelltemp = 1, &shellxquot
e = '', &shellxescape = ''
syntastic: 302.556203: UpdateErrors (auto): default checkers
syntastic: 302.556277: _skip_file: skipping checks
I'm running rubocop version 0.29.0 and ruby version 2.2.1 (through RVM).
This is in iTerm2 with vim version 7.4 Included patches: 1-488 (compiled by homebrew).
I should mention that running SyntasticCheck directly works perfectly fine. It's just the auto-running of that command that isn't working.
As a temporary workaround I added this:
noremap :w<CR> :w<CR>:SyntasticCheck<CR>
And here is the output of running that command:
syntastic: 573.438674: &shell = 'bash', &shellcmdflag = '-c', &shellpipe = '2>&1| tee', &shellquote = '', &shellredir = '>%s 2>&1', &shellslash = 0, &shelltemp = 1, &shellxquot
e = '', &shellxescape = ''
syntastic: 573.438810: UpdateErrors (auto): default checkers
syntastic: 573.438886: _skip_file: skipping checks
syntastic: 573.455481: &shell = 'bash', &shellcmdflag = '-c', &shellpipe = '2>&1| tee', &shellquote = '', &shellredir = '>%s 2>&1', &shellslash = 0, &shelltemp = 1, &shellxquot
e = '', &shellxescape = ''
syntastic: 573.455657: UpdateErrors: default checkers
syntastic: 573.455889: CacheErrors: default checkers
syntastic: 573.456816: g:syntastic_aggregate_errors = 0
syntastic: 573.456988: getcwd() = '/Users/jon/Sites/Rails/project'
syntastic: 573.457300: CacheErrors: Invoking checker: ruby/mri
syntastic: 573.457853: SyntasticMake: called with options: {'errorformat': '%-G%\m%.%#warning: %\%%(possibly %\)%\?useless use of == in void context,%-G%\%.%\%.%\%.%.%#,%-GSynt
ax OK,%E%f:%l: syntax error\, %m,%Z%p^,%W%f:%l: warning: %m,%Z%p^,%W%f:%l: %m,%-C%.%#', 'makeprg': 'ruby -w -T1 -c app/models/application_document.rb', 'env': {'RUBYOPT': ''}}
syntastic: 573.503589: getLocList: checker ruby/mri returned 0
syntastic: 573.504400: CacheErrors: Invoking checker: ruby/rubocop
syntastic: 573.505274: SyntasticMake: called with options: {'subtype': 'Style', 'errorformat': '%f:%l:%c: %t: %m', 'makeprg': 'rubocop --format emacs app/models/application_doc
ument.rb'}
syntastic: 574.301038: getLocList: checker ruby/rubocop returned 1
So you can see the first 4 lines when it's trying to run the UpdateErrors (auto) function, it fails, but when it runs just the normal UpdateErrors function later (because I manually told it to), then it works fine... any thoughts?
Thanks!
Does the problem happen for all Ruby file? Does it happen every time you save the files (i.e. saving the file multiple times doesn't "make it work")? Can you still reproduce the problem if you disable all other plugins? Do you have autocmds on write in your vimrc?
Ping.
I did a vundle update yesterday and when I tested things this morning it seems that sometimes now :w will run syntastic check automatically. It wasn't consistent yet though. For some files it still didn't auto-run, but I was dealing with an open vim session. I'll do some more experimentation today and see how it goes.
This particular code path hasn't changed in a long while. When you stumble upon a file that doesn't get checked with :w please run :SyntasticInfo against it immediately (the point being that it should explain why the checks are skipped).
A file gets skipped for one of the following reasons:
b:syntastic_skip_checks is set for the corresponding bufferbuftypefilereadable())w:diff is set in the current windowg:syntastic_ignore_filesg:syntastic_ignore_extensions.The SyntasticInfo command tries this exact conditions and shows you the result. If for some reasons it doesn't, there's something wrong with your Vim...
@lcd047 thanks for the replies on this. I found the offending plugin. Seems that 'nerdtree-git-plugin' is doing something to update some flags in NERDTree and something is wonky with showing the syntastic signs then at that point. I commented on a closed ticket on that project that seems to be related: https://github.com/Xuyuanp/nerdtree-git-plugin/issues/6 Hopefully I'll get some answers over there. Thanks again!
Yes, welcome to the wonderful world of autocmd madness. Because of this write, nerdtree-git-plugin needs a nested keyword to the autocmd here. Add it before call, and you should be fine. See :help autocmd-nested.
In my case, making the autocmd nested did not help. What helped was renaming the sysntastic directory to something that alphabetically comes before nerdtree-git-plugin.
@RST-J You see, that's the thing with thread necromancing, the world has moved on since the last post. autocmds in Vim have changed a few times, at least once (I think) in a way relevant to your problem. It might be worth reporting this to vim_dev.
This pull request provides a solution.
The problem was not due to autocmd-nested:
By default, autocommands do not nest. For example, if you use ":e" or ":w" in
an autocommand, Vim does not execute the BufRead and BufWrite autocommands for
those commands.
It is due to the fact that when a file is opened outside of NERDTree, NERDTree has no knowledge of it. b:NERDTree.root.findNode(g:NERDTreePath.New(a:fname)) returns {}, and the function is returned without returning to the previous window.
Most helpful comment
Yes, welcome to the wonderful world of
autocmdmadness. Because of this write, nerdtree-git-plugin needs anestedkeyword to theautocmdhere. Add it beforecall, and you should be fine. See:help autocmd-nested.