(See update at bottom)
I feel like I\'m missing something terribly obvious here, but I can\'t change gemsets from within a shell script. This minimal script demons
I ended up implementing the functionality I wanted as a function instead of a shell script.
function rvmrc {
rvm gemset create $1
rvm gemset use $1
echo "rvm gemset use $1" > .rvmrc
rvm rvmrc trust
}
Had exactly the same problem, and here's the solution:
#!/bin/bash
# IMPORTANT: Source RVM as a function into local environment.
# Otherwise switching gemsets won't work.
[ -s "$HOME/.rvm/scripts/rvm" ] && . "$HOME/.rvm/scripts/rvm"
# Enable shell debugging.
set -x
rvm 1.9.2@gemset_a
rvm gemdir
gem env gemdir
rvm 1.9.2@gemset_b
rvm gemdir
gem env gemdir
What I've found out is that your interactive shell has got rvm()
and its helpers, whereas script's environment has not got them. rvm
binary is executed instead, partially working and thus causing some confusion.