Any way to run rvm from Ruby system command?

81 views
Skip to first unread message

Adam Meehan

unread,
Oct 2, 2009, 1:37:23 AM10/2/09
to rvm (Ruby Version Manager)
I would like to try to integrate rvm into a project which controls gem
versions for your test environment http://github.com/adzap/ginger The
plan is to add ruby version control on the fly too, using rvm.

Problem is I just can't seem to find a way to call rvm from Ruby using
any of the system process methods. The 'rvm' command doesn't work
presumably because some bash magic going on. Also calling any of the
bash scripts directly fails with path errors or similar. Would you
have any suggestions?

Thanks for the great work on rvm, its fantastic.

Adam

Wayne Seguin

unread,
Oct 2, 2009, 6:25:40 AM10/2/09
to rubyversi...@googlegroups.com, Wayne Seguin
Adam,

There is a small bit of overhead at the moment as that use case hasn't
come up yet :)

Currently lets say for example you want to run somthing against 1.9.1:

result=`source ~/.bash_profile ; rvm 1.9.1 ; <<what you want to run
goes here>>`

If that gives you trouble instead of simply sourcing bash_profile you
can alternatively do:

result=`bash -l -c 'rvm 1.9.1 ; <<what you want to run goes here>>'`

Or maybe running specs against multiple ruby versions and nab the
result as JSON:

json_result=`source ~/.bash_profile ; rvm 1.9.1,1.8.6,jruby rake spec`
json = JSON.parse(json_result)
...

I have added a PT story to make this easier in the future so keep an
eye on the next few releases.

~Wayne

Adam Meehan

unread,
Oct 2, 2009, 6:56:09 AM10/2/09
to rubyversi...@googlegroups.com
Thanks Wayne!

I had tried previously sourcing the .bash_profile but to no avail. But the bash
call works! I can now play with that and see how I go.

Thanks again.

Adam
Reply all
Reply to author
Forward
0 new messages