Trouble setting up rubocop with Sublime
14 Oct 2018Using Sublime Text 3, RVM and want to set up robocop?
Make sure you have installed rubocop in your default ruby version.
gem install rubocop
Open the command palette, press ctrl+shift+p (Win, Linux) or cmd+shift+p (OS X). Start by typing Package Controll: Install Package
.
Now search for the rubocop package. Just select the package and hit enter.
Once installed you can see the package options in the tool bar
Open any ruby file and run ‘Rubocop Check Single File’
Troubleshoot
Sometimes after all the installation, you may see /bin/sh: 1: /home/al/.rvm/bin/rvm-auto-ruby: not found
, sublime just cannot find your ruby path.
Lets find out the path first, go to console and run
al@al$ which rvm-auto-ruby
/usr/share/rvm/bin/rvm-auto-ruby
Open Preferences > Package Settings > Rubocop > Settings - User
and add
{
// The path to RVM's rvm-auto-ruby binary
"rvm_auto_ruby_path": "/usr/share/rvm/bin/rvm-auto-ruby"
}
Replace the path with the output of the which rvm-auto-ruby
command.