28 Dec 2012

How to make SublimeLinter work with Ruby & RVM


If you're using SublimeLinter with Sublime Text 2 on Rails projects using RVM, then you might have noticed some lines are displayed as being errors when they're actually not.

format.html lines are reported as containing errors

This is because SublimeLinter is using the system ruby, instead of the ruby for your gemset. See, the Ruby linter that SublimeLinter uses is extremely simple. It just runs the code through ruby -wc and marks any output in the code. But that's the problem. Sublime Text 2 isn't using the ruby that your Rails app uses.

You can change the SublimeLinter settings to correct this issue by opening the Sublime Text 2 menu, going into Preferences -> Package Settings -> SublimeLinter, and selecting Settings - User. Add this text to the file, save it, and restart Sublime Text 2:

{

    "sublimelinter_executable_map":
    {
        "ruby": "rvm-auto-ruby"
    }

}

The old way we had to fix this problem was to go through the package files themselves:

  • Hold the option key down
  • Click the Go menu in Finder
  • Select Library
  • Navigate into Application Support/Sublime Text 2/Packages/SublimeLinter/sublimelinter/modules
  • Open the file ruby.py in Sublime Text 2
  • Change line 10 from 'executable': 'ruby', to 'executable': '/Users/YOUR-USER-NAME/.rvm/bin/rvm-auto-ruby',
  • Restart Sublime Text 2

The drawback to this workaround was that if/when SublimeLinter was updated, you would lose this edit. Good thing we don't need to worry about that, anymore!

Tags

sublime-text-2 sublimelinter ruby rvm

Related Posts

16 Oct 2009 Holyoke's Center City Vision Plan
19 Jan 2012 How Multi-File Search in BBEdit improved my workflow
09 Dec 2012 The tech behind getting Blizzalert into its third season
30 Mar 2012 I put together the site for JeffreyB Photography
20 Jan 2012 Using a custom version of Git on Mac OS X Lion