MacOS – Getting Sublime text to use the latest version of Ruby

macossublimetexttext-editor

I have multiple versions of Ruby installed on my machine. By using RVM, I am able to use Ruby 1.9.2 on the terminal. But whenever, I use Sublime Text, the text editor of my choice, it defaults to using Ruby 1.8.7. How do i change this behavior?

Best Answer

This worked for me.

Update ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Ruby/Ruby.sublime-build

{
  "env":{
      "PATH":"${HOME}/.rvm/bin:${PATH}"
  },
  "cmd": ["rvm-auto-ruby", "$file"],
  "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
  "selector": "source.ruby"
}

The env part will add rvm-auto-ruby into the $PATH and the cmd will execute rvm-auto-ruby yourfile.rb when you press Cmd-B. You and add options in between rvm-auto-ruby if you want, like this `”cmd”: [“rvm-auto-ruby”, “-S”, “$file”].

From here:
http://rubenlaguna.com/wp/2012/12/07/sublime-text-2-rvm-rspec-take-2/