tomoya / rubocop-auto-correct

Auto-correct ruby source code by using rubocop in Atom.
https://atom.io/packages/rubocop-auto-correct
MIT License
29 stars 17 forks source link

Finding which Rubocop path to use #24

Closed janwerkhoven closed 8 years ago

janwerkhoven commented 8 years ago

Hi,

I had to update Rubocop Command Path to make your package work. In the documentation you may want to add how users can do that. That would have helped me and will probably save other people some time.

For users to find their Rubocop path they can type which rubocop

which rubocop
/Users/Jan/.rvm/gems/ruby-2.2.3/bin/rubocop

Copying that was not enough. I had to replace /bin with /wrappers to make it work.

For Ruby experts this makes perfect sense, but for me this took quiet a while to figure out.

Thanks for the package!

tomoya commented 8 years ago

Hi @janwerkhoven,

Thank you for your nice suggestion. I will update documentation. But, If you have a time, please send me a pull-request. It makes me happy.

Thank you,

janwerkhoven commented 8 years ago

My suggestion above does not seem to work anymore... I keep getting these errors. Following the URL did not make me any wiser... Do you have any suggestions how to resolve this?

screen shot 2016-03-17 at 11 12 28 am

warning: parser/current is loading parser/ruby21, which recognizes warning: 2.1.7-compliant syntax, but you are running 2.1.2. warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.

which rubocop
/Users/Jan/.rvm/gems/ruby-2.2.3/bin/rubocop

Console says 2.2.3, error says 2.1.7 code, but running 2.1.2... What's going on??

tomoya commented 8 years ago

I have not been able to find the cause yet. I need your help. I think you are using RVM. Do your Ruby environments have a difference between global and project local? If you have it, I guess that there is the cause around it.

janwerkhoven commented 8 years ago

1. rvm -v rvm 1.27.0 (latest)

2. which rubocop /Users/Jan/.rvm/gems/ruby-2.1.2/bin/rubocop

3. cd (to exit my project) which rubocop sh: command not found: rubocop

4. gem install rubocop Resolves this error 👍

So the Rubocop gem was installed in my Rails project only. Installing it in my user root, resolved the error. Your package no longer throws that error. Now I'm getting these :)

screen shot 2016-05-17 at 2 48 56 pm

Getting closer

janwerkhoven commented 8 years ago

All right fixed! Had to run rubocop --auto-gen-config in the .rubocop_todo.yml file in Rails.

lacostenycoder commented 3 years ago

I have the version of rubocop installed for my project ( 0.57.2 ), it runs fine from the terminal but I get this when running in Atom version 1.53.0 Screen Shot 2021-01-01 at 11 17 44 AM

when I try with path to

which rubocop
/Users/lacoste/.rvm/gems/ruby-2.6.4/bin/rubocop

I get Screen Shot 2021-01-01 at 11 20 37 AM

¯\_(ツ)_/¯
janwerkhoven commented 3 years ago

@lacostenycoder My experience was that even though I had gem 'rubocop' in Gemfile, rubocop-auto-correct seems to ignore that version. Instead it's expecting a globally installed gem. Have you tried running gem install rubocop?

janwerkhoven commented 3 years ago

A good addition to rubocop-auto-correct is the linter-rubocop. The linter highlights errors, warnings and best practice suggestions with links to the rubocop rules. This has helped me understand why certain rules are best practice before auto-correcting them.