mipmip
5/21/2014 - 11:53 AM

Set ruby version for Mavericks, choose between 1.8 end 2.0

Set ruby version for Mavericks, choose between 1.8 end 2.0

#!/bin/sh

while getopts ":a :b" opt; do
    case $opt in
        a)
            cd /System/Library/Frameworks/Ruby.framework/Versions/
            sudo rm Current
            sudo ln -sf /System/Library/Frameworks/Ruby.framework/Versions/1.8 Current
            sudo rm -rf /usr/bin/ruby
            sudo ln -sf /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby /usr/bin/ruby
            echo "-a set ruby 1.8.7" >&2
            ;;
        b)
            cd /System/Library/Frameworks/Ruby.framework/Versions/
            sudo rm Current
            sudo ln -sf /System/Library/Frameworks/Ruby.framework/Versions/2.0 Current
            sudo rm -rf /usr/bin/ruby
            sudo ln -sf /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby /usr/bin/ruby
            echo "-b set ruby 2.0" >&2
            ;;
        \?)
            echo "Invalid option: -$OPTARG" >&2
            echo "use -a for 1.8 and -b for 2.9" >&2
            ;;
    esac
done
echo "current version:" >&2
/usr/bin/ruby -v