Home Download Buy Blog Forum Support

Building Ruby and using RVM

Building Ruby and using RVM

Postby dsr on Sun Oct 02, 2011 8:22 pm

I'm playing with the Ray library which I've installed into my RVM environment.

When I try to build it in Sublime Text 2, I get an error that it can't find Ray. Launching it from Terminal is just fine.

I don't think it's seeing the RVM environment?
dsr
 
Posts: 6
Joined: Sun Sep 11, 2011 2:35 pm

Re: Building Ruby and using RVM

Postby dsr on Mon Oct 03, 2011 2:25 pm

I think a better way of asking is: How do I make ST2 use the ruby set by RVM?

Am I the only one running into this?
dsr
 
Posts: 6
Joined: Sun Sep 11, 2011 2:35 pm

Re: Building Ruby and using RVM

Postby JayCarroll on Thu Oct 06, 2011 4:00 pm

I have the same issue, the trick is going to be using $MY_RUBY_HOME in Ruby.sublime-build. I'll post back if I have any success.

Some docs:

http://www.sublimetext.com/docs/build

http://sublimetext.info/docs/en/referen ... stems.html
JayCarroll
 
Posts: 1
Joined: Thu Oct 06, 2011 3:57 pm

Re: Building Ruby and using RVM

Postby forehead on Thu Oct 06, 2011 6:15 pm

I wasn't able to get $MY_RUBY_HOME working. My solution was to insert the full path to my RVM bin dir inside my Ruby.sublime-build:

Code: Select all
{
   "cmd": ["/Users/alex/.rvm/bin/ruby", "-cw", "$file"],
   "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
   "selector": "source.ruby"
}


Note that I'm using the Build command to check syntax, not to run the file, so I'm using the "-cw" flags. (I'm using a hacked RubyTest plugin to run.)

Question: should I put this inside Packages/Ruby/Ruby.sublime-build or Packages/User/Ruby.sublime-build ?
forehead
 
Posts: 20
Joined: Wed Oct 05, 2011 10:32 pm

Re: Building Ruby and using RVM

Postby dsr on Fri Oct 07, 2011 7:02 pm

Thanks for the answer!

I put my in Packages/User/Ruby-RVM.sublime-build just so it doesn't clash with any defaults.
dsr
 
Posts: 6
Joined: Sun Sep 11, 2011 2:35 pm

Re: Building Ruby and using RVM

Postby n00ge on Sat Oct 08, 2011 2:53 pm

@forehead How are you getting RubyTest to work? Whenever I run it I get '/bin/sh: rspec: command not found'. It works fine from the command line though. Any ideas?
http://twitter.com/n00ge
Sublime Text 3 dev builds | OS X 10.8.2 & Ubuntu 13.04
n00ge
 
Posts: 140
Joined: Mon Oct 05, 2009 1:23 am

Re: Building Ruby and using RVM

Postby forehead on Sun Oct 09, 2011 2:21 pm

@n00ge here's my RubyTest.sublime-settings, in which i had to put the full paths to my exes.

Code: Select all
{
  "ruby_unit_exec": "/Users/alex/.rvm/bin/ruby -Itest",
  "ruby_cucumber_exec": "cucumber",
  "ruby_rspec_exec": "/Users/alex/.rvm/bin/rvm 1.9.2 exec bundle exec rspec"
}


Yes, it's annoying. ;)
forehead
 
Posts: 20
Joined: Wed Oct 05, 2011 10:32 pm

Re: Building Ruby and using RVM

Postby forehead on Sun Oct 09, 2011 2:26 pm

@dsr if you put settings in Ruby-RVM.sublime-build, then how do they get loaded? I'm fuzzy on how ST2 makes the mapping between file name and build system...

And along those lines, I'd like to have one build system (i.e. "command that gets run when I hit cmd-B") for .rb files, another for _test.rb files, and yet another for _spec.rb files. Any ideas on how to get that kludged up?
forehead
 
Posts: 20
Joined: Wed Oct 05, 2011 10:32 pm

Re: Building Ruby and using RVM

Postby dsr on Sun Oct 09, 2011 10:53 pm

I manually select the build from the menu item. I'm not sure how you would map it to automatically select it for all .rb files.
dsr
 
Posts: 6
Joined: Sun Sep 11, 2011 2:35 pm

Re: Building Ruby and using RVM

Postby n00ge on Mon Oct 10, 2011 3:38 pm

Last I remember, I think @jps broke up the extensions by periods. I'm not sure if looking for _spec.rb would be possible but it would certainly be handy. Maybe he can verify.
http://twitter.com/n00ge
Sublime Text 3 dev builds | OS X 10.8.2 & Ubuntu 13.04
n00ge
 
Posts: 140
Joined: Mon Oct 05, 2009 1:23 am

Next

Return to Technical Support

Who is online

Users browsing this forum: Elengar, Exabot [Bot] and 21 guests