Search code examples
ruby-on-railsrubyatom-editoratom-beautify

Atom Beautify Ruby with rubocop doens't work


I have Atom Beautify plugin installed in Atom and the rubocop gem installed in my app. Even after these steps the beautify don't work.

My rubocop location:

  $ which rubocop 
  /home/leonardo/.rbenv/shims/rubocop

In my config.cson i have the code:

...
    ruby:
      rubocop_path: "/home/leonardo/.rbenv/shims/rubocop"
...

When I try using Beatify(Ctrl+Alt+B) this return the error:

Error: rbenv: rubocop: command not found
The `rubocop' command exists in these Ruby versions:
  2.4.3
    at /home/leonardo/.atom/packages/atom-beautify/src/beautifiers/executable.coffee:182:23
    at tryCatcher (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:693:18)
    at Async._drainQueue (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:143:10)
    at Async.drainQueues (/home/leonardo/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:17:14)
    at process._tickCallback (internal/process/next_tick.js:103:7)

Solution

  • I was having the same problem. My project was on version 2.2.2 and rubocop gem was installed on this version.

    Atom was running atom-beautify, but using the global rbenv version (in my case was 2.4.0) and that was causing the error. So the solution was:

    $ cd ~
    $ rbenv version
    2.4.0
    $ gem install rubocop
    

    Then restart Atom, run atom-beautify and everything should be fine now.