3

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)
L Y E S - C H I O U K H
  • 4,765
  • 8
  • 40
  • 57
Léo Rocha
  • 324
  • 3
  • 13
  • Is there a chance that you switched to ruby version without rubocop gem installed? – Martin Mar 13 '18 at 18:46
  • It will give a lot of work. The project is already advanced. The problem can be this? – Léo Rocha Mar 13 '18 at 18:56
  • I mean error message says that `rubocop` command exists in ruby 2.4.3 but if you switched to a project with different ruby version you might need to install `rubycop` for that – Martin Mar 13 '18 at 19:50
  • But my project is in the version 2.4.3 of ruby and rubocop is installed on it :S – Léo Rocha Mar 13 '18 at 20:14

2 Answers2

6

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.

ADM
  • 20,406
  • 11
  • 52
  • 83
0

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.

bvh
  • 443
  • 4
  • 10