chruby icon indicating copy to clipboard operation
chruby copied to clipboard

how to switch between the same version of ruby

Open mikeni opened this issue 9 years ago • 2 comments

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

  • ruby-2.2.0 ruby-2.2.0

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 avatar Jan 28 '15 12:01 mikeni

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

mikeni avatar Jan 29 '15 12:01 mikeni

Sounds reasonable to search $RUBIES in reverse order.

postmodern avatar Feb 12 '15 02:02 postmodern