Léo Rocha
Léo Rocha

Reputation: 324

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)

Upvotes: 3

Views: 767

Answers (2)

bvh
bvh

Reputation: 443

I ran into the same problem the other day. I'm using Ruby 2.7.4 and to get the path for Atom Beautify to use I used rbenv which rubocop instead of which rubocop.

$ rbenv which rubocop
/Users/YourUsername/.rbenv/versions/2.7.4/bin/rubocop

Afterwards, copy and paste the above path to Atom Beautify's settings --> Executables --> Rubocop --> Binary/Script Path text field. And then restart Atom.

Upvotes: 0

Danilo Rodrigues
Danilo Rodrigues

Reputation: 143

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.

Upvotes: 6

Related Questions