Last Updated: February 25, 2016
·
648
· jinnko

Upgrade stock ruby1.8 to ruby1.9.1 on debian squeeze

This one liner will check whether ruby1.8 is installed, then remove all gems and ruby1.8 packages before installing the stock ruby1.9.1 packages and set up all the necessary links with update-alternatives.

aptitude search ruby | grep '^i' | grep -q ruby1.8  && gem list | grep -E '^[a-z]' | awk '{print $1}' | while read GEM; do gem uninstall -a $GEM; done && aptitude remove -fy ruby ruby-dev rubygems && aptitude -fy install ruby1.9.1 ruby1.9.1-dev && update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 10 --slave /usr/share/man/man1/ruby.1.gz ruby.1.gz /usr/share/man/man1/ruby1.9.1.1.gz --slave /usr/bin/erb erb /usr/bin/erb1.9.1 --slave /usr/bin/gem gem /usr/bin/gem1.9.1 --slave /usr/bin/irb irb /usr/bin/irb1.9.1 --slave /usr/bin/rake rake /usr/bin/rake1.9.1 --slave /usr/bin/rdoc rdoc /usr/bin/rdoc1.9.1 --slave /usr/bin/testrb testrb /usr/bin/testrb1.9.1 --slave /usr/share/man/man1/erb.1.gz erb.1.gz /usr/share/man/man1/erb1.9.1.1.gz --slave /usr/share/man/man1/gem.1.gz gem.1.gz /usr/share/man/man1/gem1.9.1.1.gz --slave /usr/share/man/man1/irb.1.gz irb.1.gz /usr/share/man/man1/irb1.9.1.1.gz --slave /usr/share/man/man1/rake.1.gz rake.1.gz /usr/share/man/man1/rake1.9.1.1.gz --slave /usr/share/man/man1/rdoc.1.gz rdoc.1.gz /usr/share/man/man1/rdoc1.9.1.1.gz --slave /usr/share/man/man1/testrb.1.gz testrb.1.gz /usr/share/man/man1/testrb1.9.1.1.gz

Thanks to finn on stackoverflow for his answer on the update-alternatives part.