Skip to content

Instantly share code, notes, and snippets.

@jzajpt
Forked from wayneeseguin/scripting_example.sh
Created September 13, 2010 07:47
Show Gist options
  • Save jzajpt/576945 to your computer and use it in GitHub Desktop.
Save jzajpt/576945 to your computer and use it in GitHub Desktop.
# Switch to Ruby 1.8.7
rvm use 1.8.7
# Print out the ruby version
ruby -v
# But the output of this is:
#
# $ ./tryrvm
# <i> Now using ruby 1.8.7 p249 </i>
# ruby 1.8.6 (2010-02-05 patchlevel 399) [i686-darwin9.8.0]
#
# Why?
#!/usr/bin/env bash
# rvm essentially has 2 methods of invocation:
#
# 1. script, ~/.rvm/bin/rvm is a *script* to execute rvm commands outside of the env
# environment. This method is an 'external script' and thus RVM would not be able
# to manage the parent shell's environment.
#
# 2. function, sourcing scripts/rvm loads rvm() as a shell *function* into a
# specific environment. Doing this will allow RVM to manage the shell environment.
#
# If the above does not make sense to you (I am assuming that several people will read
# this) please hop on IRC and let's chat.
#
# As an additional note, rvm has two verbosity modes
#
# $ rvm use X # This will output 'now using X' and is
# # and is not necessairly meant for scripting.
#
# $ rvm X # This will use X but not output anything
# # and is meant for use with scripting.
#
source $HOME/.bashrc # if rvm is sourced there.
# alternatively you can: source $HOME/.rvm/scripts/rvm
# Select 1.8.7
rvm use 1.8.7
# Output the current ruby version
ruby -v
# Display the information about the current environment, within this script.
rvm info
# Display the current rubygems directory for environment, within the script.
rvm gemdir
# List installed rubies
rvm list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment