postmodern / chruby

Changes the current Ruby
MIT License
2.86k stars 190 forks source link

how to switch between the same version of ruby #317

Open mikeni opened 9 years ago

mikeni commented 9 years ago

I installed two versions of the same ruby version

1.) ruby-install ruby 2.2.0

Successfully installed ruby 2.2.0 into /home/mike/.rubies/ruby-2.2.0

2.) cd /home/mike/manual_install_ruby-install_sudo/ruby-install-0.5.0/bin sudo ./ruby-install ruby 2.2.0

Successfully installed ruby 2.2.0 into /opt/rubies/ruby-2.2.0

when i run the "chruby" command, I get chruby

the reason for this is because, for a.) I use the ruby to load the passenger gem to install passenger/nginx for web server purposes

for b.) I want a ruby with gems specific for the user

when i run "chruby ruby-2.2.0", I always end up with the ruby installed into /opt/rubies/ruby-2.2.0

is there anyway to choose between the two?

mikeni commented 9 years ago

ok after reading the chruby.sh file, i see that it iterates through the RUBIES and breaks as soon as it finds a match

I guess if I have installed rubies in both /opt/rubies and ~/.rubies , then I should write a custom chruby.sh where I switch the order like, the following below, to have priority with local rubies?

for dir in "$HOME/.rubies" "$PREFIX/opt/rubies"; do [[ -d "$dir" && -n "$(ls -A "$dir")" ]] && RUBIES+=("$dir"/*) done unset dir

postmodern commented 9 years ago

Sounds reasonable to search $RUBIES in reverse order.