Scripting an rvm command

Hi All,

sorry for this dumb question, but i’m getting zero iq as of this moment
:slight_smile:

i cannot seem to run properly an rvm command inside a script file. my
objective is to run a ruby script on all rvm versions installed.

eg, the ff runs fine when run thru the cli,

for i in rvm list strings; do rvm use “$i”; ruby -v; done

but when the above code is placed inside a script file, and then the
script is run, you wont get the expected output. You just the same
ruby -v result on all rvm ruby versions, as if rvm use command was
ignored…

hope i was clear enough.

thank you and kind regards
-botp

ok, ignore. sorry for the noise.

found out that i have to source “$HOME/.rvm/scripts/rvm”
should have read seguin’s page in advance.

kind regards -botp

On Thu, Nov 11, 2010 at 7:48 AM, botp [email protected] wrote:

but when the above code is placed inside a script file, and then the
script is run, you wont get the expected output. You just the same
ruby -v result on all rvm ruby versions, as if rvm use command was
ignored…

I just noticed your update, so I deleted more than half my response.
But I wanted to mention that in addition to the ways outlined on that
page, I find that wrapping version changes inside a bash function
works well and is quite handy. Here’s one example from a recent
project:

A quick and dirty solution to run my specs through multiple ruby versions. · GitHub

Then in the console, running ./multispec.sh does the job nicely.

Regards,
Ammar

On Thu, Nov 11, 2010 at 2:12 PM, Ammar A. [email protected]
wrote:

I just noticed your update, so I deleted more than half my response.
But I wanted to mention that in addition to the ways outlined on that
page, I find that wrapping version changes inside a bash function
works well and is quite handy. Here’s one example from a recent
project:
A quick and dirty solution to run my specs through multiple ruby versions. · GitHub
Then in the console, running ./multispec.sh does the job nicely.

yes, the script does work as written verbatim in cli and as shell
function, wc baffled me much why i cannot run it fine inside a script
file. i have in fact now included the sourcing inside the function.
this way i wont forget it :slight_smile:

thanks Ammar for the multispec tip.

best regards -botp