SublimeLinter / SublimeLinter-rubocop

SublimeLinter 3 plugin for Ruby, using rubocop.
MIT License
160 stars 40 forks source link

no rubocop version could be extracted warning #21

Closed robwise closed 9 years ago

robwise commented 9 years ago

I was wondering if I could get some help troubleshooting—I'm not getting any Rubocop linting to show up and I've exhausted the suggestions in the docs (or so I think).

ST3 debug mode printout when I open a .rb file

SublimeLinter: rubocop version query: /usr/bin/ruby -S rubocop --version 
SublimeLinter: WARNING: no rubocop version could be extracted from:
/usr/bin/ruby: no Ruby script found in input (LoadError)

Environment

Steps Taken As you can see, it seems to be looking for the rubocop gem in /usr/bin/ruby for some reason and then can't find it. Edit: @reconbot has pointed out that I am misreading the error message, as the plugin is trying to run ruby, not the rubocop gem here.

This has happened only after I switched from using Bash to using ZSH. ST3 rubocop linting was working then, and the gem itself continues to work from the command line. In case it's helpful:

~ which rubocop
/Users/Rob/.rbenv/shims/rubocop
~ rubocop -version
0.31.0

I have made sure that my path variables (including ~/.rbenv/shims are set in ~/zprofile). I tried to troubleshoot by adding that path directly in my SublimeLinter user settings paths section as well.

Also, as directed, I moved the weird eval "(rbenv init - zsh)" line to ~/.zprofile as well. Note that this includes that zsh part after the hyphen, which is not how it is in the docs, but ZSH yells at me if I don't put that in there (https://github.com/sstephenson/rbenv/issues/487).

Relevant Paths section from ST3 debug console

SublimeLinter: debug mode: on 
SublimeLinter: temp directory: /var/folders/kq/bc819ndd2z794gj85khrp6p00000gn/T/SublimeLinter3-Rob 
SublimeLinter: user shell: /bin/bash 
SublimeLinter: computed PATH using /bin/bash:
~/.rbenv/shims/rubocop
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Users/Rob/.rbenv/shims
/usr/local/bin/npm
/usr/local/bin/node
/Users/Rob/.npm_modules/lib/node_modules
/Users/Rob/.npm_modules/bin
/usr/local/Cellar/qt5/5.3.1/bin
/Users/Rob/Applications/Postgres.app/Contents/Versions/9.3/bin
/usr/X11/bin
/usr/local/mysql/bin
/usr/local/sbin
/Users/Rob/.rbenv/bin
reconbot commented 9 years ago

The plugin runs ruby not rubocop. I'm not familiar enough with rbenv to know if that matters.

robwise commented 9 years ago

@reconbot I edited my post to ensure I don't spread misinformation.

After reading your comment, I became even more suspicious that it was a PATH problem due to some weird issue with rbenv and ZSH. It seems ST3 was using/detecting my shell as Bash instead of ZSH, and therefore was not loading my specified PATHs. The SublimeLinter documentation seems to indicate that it should be able to tell that I use ZSH, but it seems that isn't the case.

This should have been overcome anyway by manually specifying the path to Ruby in the paths section of the SublimeLinter settings in ST3. However, like an idiot, I had specified the ~/.rbenv/shims/rubocop directory instead of just ~/.rbenv/shims as directed here in the troubleshooting guide.

Because you pointed out the plugin is running ruby and not rubocop anyway, I quickly found this error and everything is working fine! Thank you!

dpikt commented 7 years ago

For future reference: if you're like me and are getting the console error:

SublimeLinter: rubocop version query: /Users/samh/.rbenv/shims/ruby -S rubocop –version 
SublimeLinter: WARNING: no rubocop version could be extracted from:
ruby: no Ruby script found in input (LoadError)

This article will help: https://sunlightfoundation.com/2015/03/31/making-sublimelinter-work-with-rbenv-and-rubocop/

pollcaz commented 7 years ago

@dpikt thanks a lot, your guide was amaizing and let me to set up successfully my ubuntu linux + zsh + rbenv + sublimelinter + rubocop, thanks again!