Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Atom-Editor: Rubocop doesn't work with atom

I was trying to connect rubocop to atom, but received the error:

linter-registry.js [sm]:144 [Linter] Error running RuboCop Error: /usr/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'rubocop' (>= 0.a) among 16 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/home/kurilovichay/.rvm/gems/ruby-2.3.1:/home/kurilovichay/.rvm/gems/ruby-2.3.1@global', execute `gem env` for more information
    from /usr/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
    from /usr/local/bin/rubocop:22:in `<main>'
    at parseFromStd (/home/kurilovichay/.atom/packages/linter-rubocop/src/index.js:41:43)
    at Object.<anonymous> (/home/kurilovichay/.atom/packages/linter-rubocop/src/index.js:212:27)
    at next (<anonymous>)
    at step (/home/kurilovichay/.atom/packages/linter-rubocop/src/index.js:11:273)

which rubocop returns:

/usr/local/bin/rubocop

can someone assist with that?

like image 407
Alexandr Kurilovich Avatar asked Apr 18 '17 18:04

Alexandr Kurilovich


2 Answers

It seems that you're using rvm to manage your environment. What i did to get it to work was follow the instructions on their repo: https://github.com/AtomLinter/linter-rubocop#settings

# make sure I'm in the global gemset
$ rvm gemset use global
# install the gem
$ gem install rubocop

configure atom to use the global. Edit your atom's config file (config.cson) and add

*:
  "linter-rubocop":
    executablePath: "~/.rvm/gems/ruby-2.3.1@global/wrappers"
  "linter-ui-default": {}

Note: make sure that the ruby version is the one you're using.

like image 106
rpbaltazar Avatar answered Nov 18 '22 23:11

rpbaltazar


I had this same issue when working on a Rails 6 application in Ubuntu 20.04 with rbenv as my ruby version manager.

I already had rubocop installed in the project, but Atom editor was still throwing this error.

All I had to do was to install the rubocop gem to be available globally on the machine. Open a new terminal and install it using:

gem install rubocop

That's all.

I hope this helps

like image 33
Promise Preston Avatar answered Nov 19 '22 01:11

Promise Preston