Easy Ruby versions from your .bashrc
Managing multiple Rubies is confusing, especially on Windows. But it doesn't need to be hard.
In your .bashrc:
export BASH_PATH=${PATH}
alias ruby18="export PATH=${RUBY18_HOME}/bin:${BASH_PATH}"
alias ruby19="export PATH=${RUBY19_HOME}/bin:${BASH_PATH}"
alias ruby20="export PATH=${RUBY20_HOME}/bin:${BASH_PATH}"
After setting RUBY*_HOME to the appropriate values, switching between Rubies is easy. Just run the appropriate alias from any new console, or from your .bashrc proper.
All your ruby commands (including irb and gem) will run with your preferred version.
Note: this will clash with bundler if you're used to running bundled gems out of ./bin without the bundle exec preface.
Written by Tyler Distad
Related protips
2 Responses
Why not use rbenv?
over 1 year ago
·
As I recall, rbenv doesn't work on Windows, even with Git Bash. I remember fighting to get it set up and never actually succeeding. Not even pik behaved as expected.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#