Flycheck: Can't make flycheck work with rubocop correctly

Created on 17 Dec 2013  路  7Comments  路  Source: flycheck/flycheck

When I open a ruby source file, emacs shows me an message in minibuffer:

Checker ruby-rubocop returned non-zero exit code 1, but no errors from output: /home/yangyu/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'rubocop' (>= 0) among 13 total gem(s) (Gem::LoadError)
    from /home/yangyu/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:309:in `to_spec'
    from /home/yangyu/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
    from /home/yangyu/.rvm/gems/ruby-2.0.0-p247/bin/rubocop:22:in `<main>'
    from /home/yangyu/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `eval'
    from /home/yangyu/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `<main>'

Checker definition probably flawed.

I have installed rubocop successfully. it works well in shell. I think this problem may be caused by environment variable,but i am not sure..

invalid

Most helpful comment

Note people coming to this issue and using rvm, curently rvm.el is unmaintained. rvm.el solved the issue for me but really slowed down my startup time. Just install rubocop globally if you don't need to export the rvm env to emacs.

rvm @global do gem install rubocop

All 7 comments

RVM causes this problem. You installed Rubocop into an RVM Ruby, but did not export the RVM environment which points to this Ruby to Emacs.

How can I do that? I have no clue. I do not use RVM. Probably @bbatsov can help.

Anyhow, this is no issue in Flycheck. Closing as "invalid".

@yuyang0 As a quick and dirty solution, you could try to disable RVM, and install Rubocop into the system Ruby.

@yuyang0 Or you may try rbenv, which does not require environment variables.

@lunaryorn I find the solution, just set GEM_PATH:

(setenv GEM_PATH "the-path")

rvm.el seems a better solution

Note people coming to this issue and using rvm, curently rvm.el is unmaintained. rvm.el solved the issue for me but really slowed down my startup time. Just install rubocop globally if you don't need to export the rvm env to emacs.

rvm @global do gem install rubocop

@TheSeldonPlan That fixed my issue, thanks.

@yuyang0 can you tell me what "the-path" is in your case (https://github.com/flycheck/flycheck/issues/288#issuecomment-30810217)?
I'm struggling to find the correct value

Was this page helpful?
0 / 5 - 0 ratings