Sublime Text 2, rbenv, osx and the build command

I’ve recently started using rbenv on OSX and was having some trouble getting the cmd+b build command in Sublime Text 2 working.

Specifically, it seemed that the wrong ruby version was being used. This caused my require ” statements to fail since it couldnt find the gems I thought I had installed.

To get things working, simply edit Ruby.sublime-build (Browse Packages -> Ruby) and update the “cmd” value to point to ~/.rbenv/shims/ruby

{
	// These are the old commands
	//"cmd": ["ruby", "$file"], 
	//"cmd": ["/usr/local/bin/ruby", "$file"],
	"cmd": ["/Users/kiwidev/.rbenv/shims/ruby", "$file"],	
	"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
	"selector": "source.ruby"
}

2 thoughts on “Sublime Text 2, rbenv, osx and the build command

    • If it doesn’t work for you, make sure you don’t have a .ruby-version file in the same directory as the file you’re trying to build.

Leave a reply to Ben Goikhman (@it_hooligan) Cancel reply