#!/bin/bash # # License: See LICENSE # # # Functions # function __rvm_meta { rvm_meta_author="Wayne E. Seguin" rvm_meta_author_email="wayneeseguin@gmail.com" rvm_meta_website="http://rvm.beginrescueend.com/" rvm_meta_version="0.0.33" rvm_meta_updated="2009.09.04" } function __rvm_version { __rvm_meta ; echo "rvm $rvm_meta_version ($rvm_meta_updated) [$rvm_meta_website]" ; } function __rvm_usage { __rvm_meta cat <<-Usage rvm ${rvm_meta_version} ${rvm_meta_website} by ${rvm_meta_author} (${rvm_meta_author_email}) Usage: rvm Action [Implementation] [Options] Action: * usage - Show this usage information use - Switch to using a specific ruby version (new login shell) info - Show information for current ruby list - Show currently installed versions gemdir - Switch to gem directory for installation (new login shell) srcdir - Switch to src directory for the current ruby installation gemdup - Clone source version gems to current version (highly expiramental) Example: rvm gemdup ~/.gem/ruby/1.8/ install - Install a ruby version, default is from source uninstall - Uninstall a ruby version reset - Remove default and current settings, exit the shell. (If you experience odd behavior try this first) rubydo - Used with -f to run a ruby file against specified or all rubies debug - Emit environment & configuration information for *current* ruby reload - Reload rvm source itself (useful after changing rvm source) implode - Removes all ruby installations it manages, everything in ~/.rvm update - Upgrades rvm to the latest version. Implementation: * ruby - MRI/YARV Ruby (The Standard), defaults to 1.8.6 jruby - jRuby rubinius - Rubinius ree - Ruby Enterprise Edition system - Use the system ruby (eg. pre-rvm state) default - Use rvm set default ruby and system if it hasn't been set. Options: -v|--version - Ruby Package Version, defaults to 'latest' -l|--level - Patch level for the specified Ruby version -p|--prefix - Package and source directory prefix, with trailing slash! Default is a users home directory and /usr/local/ for root -c|--configure - Options for source compile (default: --enable-shared=true) -a|--archives - Directory to place downladed files into (~/.rvm/archives/) -n|--nice - Niceness level (default: 0) -m|--gem-set - Named gem set for switching between different gem sets --rm-gem-set - Removes a named gemset. -l|--level - Specify a patch level to use -t|--tag - -r|--rev - Specify the repository revision # to use or 'head' for -P|--prefix - Sets the prefix path for installs to be installed to -B|--bin - Specify path for binaries to be placed -S|--source - Specify src directory to use -A|--archive - Specify archive directory to use (tabralls / zips) -G|--gems - Specify root gem path to use -C|--configure - Specify custom configure options, comma separated -M|--make - Specify a custom make command -I|--make-install - " a custom make install command -n|--nice - Specify a process niceness (for slow computers) -f|--file - Specify a ruby file to run with 'rubydo' command -h|--help - Emit this output and exit -d|--default - Set the default Ruby to a specified version -m|--gem-set - Use a named gem set instead of the default set. --all - Used with 'rvm list' to list "most" installable versions. --rm-gem-set - Remove a named gem set --jit - Enable JIT for the Rubinius build --force - Force install, removes old install & source directories. --set-prompt - Set prompt to have the selected ruby prepended. --debug|--trace - Toggle debug mode on for very verbose output. Resources: http://rvm.beginrescueend.com/ https://www.pivotaltracker.com/projects/26822 Usage } # Logging functions based on level function __rvm_log { case "$1" in debug) shift ; echo -e "\n\033[0;35m $* \033[0m" ;; info) shift ; echo -e "\n\033[0;32m $* \033[0m" ;; warn) shift ; echo -e "\n\033[0;33m $* \033[0m" ;; fail) shift ; echo -e "\n\033[0;31m $* \033[0m" ; popd 2> /dev/null ; return 1 ;; *) echo -e "$*" esac } function __rvm_clean-path { PATH=`echo $PATH | tr -s ':' '\n' | awk '!($0 in a){a[$0];print}' | tr -s '\n' ':' | sed 's/:$//'` export PATH } function __rvm_remove-from-path { PATH=`echo $PATH | tr -s ':' '\n' | grep -v "\.rvm" | tr -s '\n' ':' | sed 's/:$//'` export PATH } function __rvm_gi { gem install -q --no-rdoc --no-ri $* ; } function __rvm_gems-install { for gem in $* ; do __rvm_gi $gem ; done } function __rvm_set-defaults { # TODO: Store defaults in "defaults/" dir. if [ ! -s $rvm_install_path/default ] ; then for variable in rvm_prompt RUBY_VERSION GEM_HOME MY_RUBY_HOME PATH ; do eval value=\$${variable} if [ -z "$value" ] ; then echo "unset ${variable}" >> $rvm_install_path/default else eval "export $variable" eval value=\$${variable} echo "${variable}='$value' ; export ${variable}" >> $rvm_install_path/default fi done fi if [ -s $rvm_install_path/default_path ] ; then rvm_default_path=`cat $rvm_install_path/default_path` else __rvm_clean-path # Clean the path the first time we compute default path. __rvm_remove-from-path echo $PATH > $rvm_install_path/default_path rvm_default_path=$PATH fi rvm_default_ps1=`__rvm_cache rvm_default_ps1` if [ -z "$rvm_default_ps1" ] ; then rvm_default_ps1=$PS1 __rvm_cache "rvm_default_ps1" "$rvm_default_ps1" fi if [ -s $rvm_install_path/default_user_gem_path ] ; then rvm_default_user_gem_path=`cat $rvm_install_path/default_user_gem_path` else ruby -r rubygems -e "puts Gem::default_path.compact.first" > $rvm_install_path/default_user_gem_path fi if [ -s $rvm_install_path/default_system_gem_path ] ; then rvm_default_system_gem_path=`cat $rvm_install_path/default_system_gem_path` else ruby -r rubygems -e "puts Gem::default_path.compact[1] || Gem::default_path.compact.first" > $rvm_install_path/default_system_gem_path fi if [ -s $rvm_install_path/default_system_ruby ] ; then default_system_ruby=`cat $rvm_install_path/default_system_ruby` else default_system_ruby=`which ruby` echo $default_system_ruby > $rvm_install_path/default_system_ruby fi } function __rvm_initialize { rvm_fetch=`which curl` if [ $? -ne 0 ] ; then rvm_fetch=`which wget` if [ $? -ne 0 ] ; then rvm_fetch="wget -q -c " else __rvm_log "fail" "rvm expects either curl or wget, neither seem to be in your path :(" fi else rvm_fetch="$rvm_fetch -O -L -s -C - " fi rvm_niceness=${rvm_niceness:-0} # TODO: Sanitize user input, ensure that there is a / a the end... if [ "`whoami`" = "root" ] ; then __rvm_log "fail" "root user support is not yet implemented." #rvm_prefix_path=${rvm_prefix_path:-/usr/local/} else rvm_prefix_path=${rvm_prefix_path:-"$HOME/."} fi if [ "${rvm_prefix_path#${rvm_prefix_path%?}}" = '.' -o "${rvm_prefix_path#${rvm_prefix_path%?}}" = '/' ] ; then rvm_install_path="${rvm_prefix_path}rvm" else rvm_install_path="${rvm_prefix_path}/rvm" fi rvm_archives_path="${rvm_archives_path:-"${rvm_install_path}/archives"}" rvm_source_path="${rvm_source_path:-"${rvm_install_path}/src"}" rvm_log_path=${rvm_log_path:-"${rvm_install_path}/log"} rvm_bin_path=${rvm_bin_path:-"${rvm_install_path}/bin"} rvm_gem_path=${rvm_gem_path:-"${rvm_install_path}/gems"} rvm_config_path=${rvm_config_path:-"${rvm_install_path}/config"} rvm_ruby_repo_url="${rvm_ruby_repo_url:-"http://svn.ruby-lang.org/repos/ruby"}" # Rubinius sha1's will be available after RC1. rvm_rubinius_repo_url="${rvm_rubinius_repo_url:-"git://github.com/evanphx/rubinius.git"}" #rvm_macruby_repo_url="${rvm_macruby_repo_url:-"http://svn.macosforge.org/repository/ruby/MacRuby"}" rvm_macruby_repo_url="${rvm_macruby_repo_url:-"git://github.com/masterkain/macruby.git"}" rvm_jruby_repo_url="${rvm_jruby_repo_url:-"git://kenai.com/jruby~main"}" __rvm_clean-path rvm_result=$(echo $PATH | grep 'rvm\/bin:') if [ -z $rvm_result ] ; then PATH=$rvm_bin_path:$PATH ; export PATH fi mkdir -p $rvm_source_path $rvm_bin_path $rvm_archives_path } function __rvm_fetch { pushd $rvm_archives_path > /dev/null eval $rvm_fetch "$1" if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi popd 2> /dev/null } # # Installer # function __rvm_run { log_file_name="1" ; shift command="$*" if [ $rvm_debug ] ; then __rvm_log "debug" "Executing: $command" ; fi eval "nice -n $rvm_niceness $command" > $rvm_ruby_log_path/log_file_name.log 2> $rvm_ruby_log_path/log_file_name.error.log if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/log_file_name.error.log" ; popd 2> /dev/null ; return 1 ; fi unset log_file command } function __rvm_install-source { if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi __rvm_log "info" "Installing Ruby from source to: $rvm_ruby_home" mkdir -p $rvm_ruby_log_path pushd $rvm_source_path > /dev/null if [ ! -z "$rvm_force" ] ; then rm -rf $rvm_ruby_home rm -rf $rvm_ruby_src_path fi if [ -z "$rvm_ruby_tag" -a -z "$rvm_ruby_rev" ] ; then if [ ! -d $rvm_ruby_src_path ] ; then rvm_url="${rvm_url:-"ftp://ftp.ruby-lang.org/pub/ruby/1.$rvm_major_version/$rvm_ruby_package_name.tar.gz"}" __rvm_log "info" "\tDownloading $rvm_ruby_package_name, this may take a while depending on your connection..." __rvm_fetch $rvm_url __rvm_log "info" "\tExtracting $rvm_ruby_package_name ..." mkdir -p $rvm_ruby_src_path # Is this line necessary considering -C below? v __rvm_run "extract" tar xzf $rvm_archives_path/$rvm_ruby_package_name.tar.gz -C $rvm_source_path fi else __rvm_log "info" "\tRetrieving Ruby from $rvm_url" if [ ! -z "`echo $rvm_url | grep '^git'`" ] ; then if [ -d "$rvm_ruby_src_path/.git" ] ; then cd $rvm_ruby_src_path if [ -z "$rvm_ruby_rev" ] ; then git pull origin master else git checkout ${rvm_ruby_rev:-HEAD} fi else git clone --depth 1 $rvm_ruby_repo_url $rvm_ruby_src_path fi else if [ -z "$rvm_ruby_rev" ] ; then # TODO: Check if tag v is valid rvm_url=$rvm_ruby_repo_url/tags/$rvm_ruby_tag rvm_rev="" else if [ "$rvm_ruby_rev" = "head" -o "$rvm_ruby_rev" = "trunk" ] ; then rvm_url=$rvm_ruby_repo_url/branches/ruby_1_${rvm_major_version}_${rvm_minor_version} rvm_rev="" else rvm_url=$rvm_ruby_repo_url/branches/ruby_1_${rvm_major_version}_${rvm_minor_version} rvm_rev="-r $rvm_ruby_rev" fi fi if [ -d "$rvm_ruby_src_path/.svn" ] ; then cd $rvm_ruby_src_path svn checkout -q $rvm_rev else svn checkout -q $rvm_rev --force $rvm_url $rvm_ruby_src_path fi fi fi cd $rvm_ruby_src_path if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi if [ ! -s "$rvm_ruby_src_path/configure" -a "$rvm_ruby_interpreter" = "ruby" ] ; then rvm_autoconf=`which autoconf` if [ $? -ne 0 ] ; then __rvm_log "fail" "rvm expects autoconf" ; fi __rvm_run "autoconf" $rvm_autoconf fi if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi if [ -s ./configure ] ; then __rvm_log "info" "\tConfiguring $rvm_ruby_package_name using $rvm_ruby_configure, this may take a while depending on your cpu(s)..." __rvm_run "configure" ./configure --prefix=$rvm_ruby_home $rvm_ruby_configure else __rvm_log "warn" "\tSkipping configure step, ./configure file does not exist." fi __rvm_log "info" "\tCompiling $rvm_ruby_package_name, this may take a while, depending on your cpu(s)..." if [ -z "$rvm_ruby_make" ] ; then __rvm_run "make" make else __rvm_run "make" $rvm_ruby_make fi if [ -z "$rvm_ruby_make" ] ; then __rvm_log "info" "\tInstalling $rvm_ruby_package_name" __rvm_run "install" make install else __rvm_run "install" $rvm_ruby_make_install fi __rvm_run "chmod.bin" chmod +x $rvm_ruby_home/bin/* __rvm_bin_scripts __rvm_log "info" "Installation of $rvm_ruby_package_name is complete." __rvm_log "info" "\tInstalling rubygems dedicated to $rvm_ruby_package_name..." rvm_gem_package_name="rubygems-1.3.5" rvm_gem_url="http://rubyforge.org/frs/download.php/60718/$rvm_gem_package_name.tgz" if [ -d $rvm_source_path/$rvm_gem_package_name ] ; then cd $rvm_source_path/$rvm_gem_package_name else __rvm_fetch $rvm_gem_url mkdir -p $rvm_source_path/$rvm_gem_package_name __rvm_run "rubygems.extract" tar zxf $rvm_archives_path/$rvm_gem_package_name.tgz -C $rvm_source_path fi # Well this is fun... fix nil error on require_paths: sed -i.orig "s/require_paths\.join/require_paths.to_a.join/" $rvm_source_path/$rvm_gem_package_name/lib/rubygems/gem_path_searcher.rb __rvm_run "rubygems.install" $rvm_ruby_binary $rvm_source_path/$rvm_gem_package_name/setup.rb popd 2> /dev/null for rvm_gem_name in rake ; do __rvm_log "info" "Installing $rvm_gem_name" __rvm_run "gems" $rvm_ruby_home/bin/gem install $rvm_gem_name --no-rdoc --no-ri -q done for binary in gem irb erb ri rdoc testrb rake ; do if [ -x $rvm_ruby_home/bin/$binary ] ; then string="ENV['GEM_HOME']='$rvm_gem_home'\nENV['PATH']='$rvm_ruby_home/bin:$rvm_gem_home/bin:$rvm_default_path'" awk "NR==2 {print \"$string\"} {print}" $rvm_ruby_home/bin/$binary > $rvm_ruby_home/bin/$binary.new mv $rvm_ruby_home/bin/$binary.new $rvm_ruby_home/bin/$binary chmod +x $rvm_ruby_home/bin/$binary else __rvm_log "warn" "$rvm_ruby_home/bin/$binary is missing" fi done __rvm_log "info" "Installation of rubygems for $rvm_ruby_package_name is complete." if [ -x $rvm_gem_home/bin/$binary ] ; then string="ENV['GEM_HOME']='$rvm_gem_home'\nENV['PATH']='$rvm_ruby_home/bin:$rvm_gem_home/bin:$rvm_default_path'" mv $rvm_gem_home/bin/$binary $rvm_gem_home/bin/$binary.orig awk "NR==2 {print \"$string\"} {print}" $rvm_gem_home/bin/$binary.orig > $rvm_gem_home/bin/$binary chmod +x $rvm_gem_home/bin/$binary else __rvm_log "warn" "$rvm_gem_home/bin/$binary is missing" fi binary=rake mv $rvm_gem_home/bin/$binary $rvm_gem_home/bin/$binary.orig awk "NR==2 {print \"$string\"} {print}" $rvm_gem_home/bin/$binary.orig > $rvm_gem_home/bin/$binary unset binary } function __rvm_install-ruby { if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi if [ -z "$RUBYOPT" ] ; then ruby_options=$RUBYOPT ; unset RUBYOPT ; fi case "$rvm_ruby_interpreter" in macruby) if [ "`uname`" = "Darwin" ] ; then rvm_ruby_repo_url=$rvm_macruby_repo_url rvm_ruby_configure="" rvm_ruby_make="rake macruby:build framework_instdir=$rvm_install_path/macruby-head framework_name=/macruby-head --trace" rvm_ruby_make_install="rake framework:install framework_instdir=$rvm_install_path/macruby-head framework_name=/macruby-head --trace" #rvm_ruby_rev="${rvm_ruby_rev:-head}" # Hard coding this for now DESTDIR="$rvm_ruby_home" ; export DESTDIR if [ -z "$rvm_ruby_rev" ] ; then # TODO: Check if tag v is valid #rvm_ruby_repo_url=$rvm_ruby_repo_url/tags/$rvm_ruby_tag rvm_ruby_rev="head" # For now, until nightly release are available. else if [ "$rvm_ruby_rev" = "head" -o "$rvm_ruby_rev" = "trunk" ] ; then #rvm_ruby_repo_url=$rvm_ruby_repo_url/trunk rvm_ruby_rev="head" else #rvm_ruby_repo_url=$rvm_ruby_repo_url/trunk rvm_ruby_rev="-r $rvm_ruby_rev" fi fi __rvm_fetch $rvm_url __rvm_run /usr/sbin/installer -pkg $rvm_ruby_package_name.pkg -target "$rvm_install_path/$rvm_ruby_package_name/" #__rvm_install-source unset DESTDIR else __rvm_log "fail" "MacRuby can only be installed on a Darwin OS." fi ;; ruby-enterprise|ree) rvm_url="http://rubyforge.org/frs/download.php/58677/$rvm_ruby_package_name.tar.gz" __rvm_log "info" "Installing Ruby Enterprise Edition from source to: $rvm_ruby_home" pushd $rvm_source_path > /dev/null if [ -d $rvm_ruby_src_path ] ; then cd $rvm_ruby_src_path else __rvm_log "info" "\tDownloading $rvm_ruby_package_name, this may take a while depending on your connection..." __rvm_fetch $rvm_url if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_ruby_log_path/*.error.log" ; popd 2> /dev/null ; return 1 ; fi __rvm_log "info" "\tExtracting $rvm_ruby_package_name..." mkdir -p $rvm_ruby_src_path __rvm_run "extract" tar xzf $rvm_archives_path/$rvm_ruby_package_name.tar.gz -C $rvm_source_path fi __rvm_log "info" "\tInstalling $rvm_ruby_package_name, this may take a while, depending on your cpu(s)..." mkdir -p $rvm_ruby_log_path cd $rvm_ruby_src_path __rvm_run "install" ./installer -a $rvm_install_path/ruby-enterprise-$rvm_ruby_version-$rvm_ruby_patch_level --dont-install-useful-gems --no-tcmalloc chmod +x $rvm_ruby_home/bin/* ln -fs $rvm_ruby_home/bin/ruby $rvm_install_path/bin/$rvm_ruby_package_name __rvm_log "info" "\tInstalling rubygems dedicated to $rvm_ruby_package_name..." rvm_gem_package_name="rubygems-1.3.5" rvm_gem_url="http://rubyforge.org/frs/download.php/60718/$rvm_gem_package_name.tgz" if [ -d $rvm_source_path/$rvm_gem_package_name ] ; then cd $rvm_source_path/$rvm_gem_package_name else __rvm_fetch $rvm_gem_url mkdir -p $rvm_source_path/$rvm_gem_package_name __rvm_run "extract" tar zxf $rvm_archives_path/$rvm_gem_package_name.tgz -C $rvm_source_path fi # Well this is fun... fix nil error on require_paths: sed -i.orig "s/require_paths\.join/require_paths.to_a.join/" $rvm_source_path/$rvm_gem_package_name/lib/rubygems/gem_path_searcher.rb > $rvm_ruby_log_path/rubygems.install.log 2> $rvm_ruby_log_path/rubygems.install.error.log __rvm_run "rubygems.install" $rvm_ruby_home/bin/ruby $rvm_source_path/$rvm_gem_package_name/setup.rb __rvm_log "info" "Installation of $rvm_ruby_package_name complete." popd 2> /dev/null for rvm_gem_name in rake ; do __rvm_log "info" "Installing $rvm_gem_name" __rvm_run "gems" $rvm_ruby_home/bin/gem install $rvm_gem_name --no-rdoc --no-ri -q done ;; rbx|rubinius) __rvm_reset # Requires 1.8 to install due to parsetree. TOOD: Check for 1.8 + parse-tree rvm_ruby_repo_url=$rvm_rubinius_repo_url rvm_ruby_configure="" rvm_ruby_make="rake" rvm_ruby_make_install="rake install" rvm_ruby_home="$rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version" #rvm_ruby_rev="head" # TODO: Check if already git repo, then git pull origin master && build if [ ! -d $rvm_ruby_home -o ! -d $rvm_ruby_home/.git ] ; then rm -rf $rvm_ruby_home git clone --depth 1 $rvm_ruby_repo_url $rvm_ruby_home fi cd $rvm_ruby_home __rvm_run "build" $rvm_rubinius_jit rake build for binary in ruby irb ; do ln -fs $rvm_ruby_home/bin/rbx $rvm_ruby_home/bin/$binary done ;; jruby) rvm_package_file="$rvm_ruby_interpreter-bin-$rvm_ruby_version" rvm_url="http://dist.codehaus.org/$rvm_ruby_interpreter/$rvm_ruby_version/$rvm_package_file.zip" rvm_jruby_repo_url="${rvm_jruby_repo_url:-"git://kenai.com/jruby~main"}" __rvm_log "info" "Installing jRuby to: $rvm_ruby_home" mkdir -p $rvm_ruby_log_path pushd $rvm_source_path > /dev/null if [ ! -z "$rvm_ruby_rev" ] ; then if [ ! -d $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version -o ! -d $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version/.git ] ; then git clone --depth 1 $rvm_jruby_repo_url $rvm_ruby_src_path cd $rvm_ruby_src_path && ant fi else if [ -d $rvm_ruby_src_path ] ; then cd $rvm_ruby_src_path else __rvm_log "info" "\tDownloading $rvm_package_file, this may take a while depending on your connection..." __rvm_fetch $rvm_url __rvm_log "info" "\tExtracting $rvm_package_file..." __rvm_run "extract" unzip -q $rvm_archives_path/$rvm_package_file.zip -d $rvm_source_path cd $rvm_ruby_src_path fi fi __rvm_log "info" "\tInstalling $rvm_ruby_package_name..." mkdir -p $rvm_ruby_home/bin/ __rvm_run "sync" rsync -ag $rvm_ruby_src_path/ $rvm_ruby_home/ __rvm_run "nailgun" cd $rvm_ruby_src_path/tool/nailgun && make popd 2> /dev/null chmod +x $rvm_ruby_home/bin/* for binary in jruby jgem jirb ; do ln -fs $rvm_ruby_home/bin/$binary $rvm_ruby_home/bin/${binary#j} done ln -fs $rvm_ruby_home/bin/ruby $rvm_install_path/bin/$rvm_ruby_package_name for rvm_gem_name in rake jruby-openssl ; do __rvm_log "info" "Installing $rvm_gem_name" __rvm_run "gems" $rvm_ruby_home/bin/jgem install $rvm_gem_name --no-rdoc --no-ri -q done ;; ruby) if [ -z "rvm_ruby_configure" ] ; then rvm_ruby_configure="--enable-shared=true" ; fi __rvm_install-source $* ;; default) __rvm_log "fail" "please specify a ruby implementation to install." ;; *) __rvm_log "fail" "Ruby implementation '$rvm_ruby_interpreter' is not known." esac if [ ! -z "$ruby_options" ] ; then RUBYOPT=$ruby_options ; export RUBYOPT fi } function __rvm_uninstall { if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi if [ ! -z "$rvm_ruby_package_name" ] ; then for dir in $rvm_source_path $rvm_install_path ; do if [ -d $dir/$rvm_ruby_package_name ] ; then __rvm_log "info" "Removing $dir/$rvm_ruby_package_name..." rm -rf $dir/$rvm_ruby_package_name else __rvm_log "info" "it seems that $dir/$rvm_ruby_package_name is already non existent." fi if [ -e $rvm_bin_path/$rvm_ruby_package_name ] ; then rm -f $rvm_bin_path/$rvm_ruby_package_name fi done ; unset dir rm -rf $rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version*/ else __rvm_log "fail" "Cannot uninstall unknown package '$rvm_ruby_package_name'" fi } # # /Installer # # __rvm_select implementation version patch_level function __rvm_select { rvm_ruby_interpreter="${1:-$rvm_ruby_interpreter}" rvm_ruby_interpreter="${rvm_ruby_interpreter:-ruby}" # Default is standard ruby if [ "$rvm_ruby_version" = "1.8" ] ; then rvm_ruby_version="1.8.6" ; fi if [ "$rvm_ruby_version" = "1.9" ] ; then rvm_ruby_version="1.9.1" ; fi case "$rvm_ruby_interpreter" in macruby) if [ "`uname`" = "Darwin" ] ; then rvm_ruby_repo_url=$rvm_macruby_repo_url rvm_ruby_version="${rvm_ruby_version:-'2009-09-04'}" # For now we are only supporting nightly builds rvm_ruby_package_name=${rvm_ruby_interpreter}_nightly-${rvm_ruby_version} rvm_url="http://dl.getdropbox.com/u/163257/$rvm_ruby_package_name.pkg" unset rvm_ruby_patch_level else __rvm_log "fail" "MacRuby can only be installed on a Darwin OS." fi ;; rbx|rubinius) rvm_ruby_version="head" rvm_ruby_version="head" unset rvm_ruby_patch_level rvm_ruby_repo_url=$rvm_rubinius_repo_url rvm_ruby_configure="" rvm_ruby_make="build" rvm_ruby_make_install="" #rvm_ruby_rev="head" ;; jruby) rvm_ruby_version="${rvm_ruby_version:-1.3.1}" unset rvm_ruby_patch_level if [ "$rvm_ruby_version" != "1.2.0" -a "$rvm_ruby_version" != "1.3.1" ] ; then __rvm_log "fail" "Unknown jRuby version: $rvm_ruby_version" fi alias jruby_ng="jruby --ng" alias jruby_ng_server="jruby --ng-server" ;; ruby-enterprise|ree) rvm_ruby_interpreter="ruby-enterprise" rvm_ruby_version=${rvm_ruby_version:-1.8.6} rvm_ruby_patch_level="${3:-20090610}" if [ "$rvm_ruby_version" != "1.8.6" ] ; then __rvm_log "fail" "Unknown Ruby Enterprise Edition version: $rvm_ruby_version" fi ;; ruby) if [ ! -z "$rvm_ruby_tag" ] ; then rvm_ruby_version=$(echo $rvm_ruby_tag | sed 's/^v//' | sed 's/\///' | awk -F'_' '{print 1 "." $2 "." $3 }') rvm_ruby_patch_level=$rvm_ruby_tag # $(echo $rvm_ruby_tag | sed 's/^v//' | sed 's/\///' | awk -F'_' '{print $4 }') fi rvm_ruby_version=${rvm_ruby_version:-1.8.6} # Default verison is 1.8.6 if [ "$rvm_ruby_version" = "1.9.1" ] ; then rvm_ruby_patch_level="${rvm_ruby_patch_level:-p243}" elif [ "$rvm_ruby_version" = "1.9.2" ] ; then rvm_ruby_patch_level="${rvm_ruby_patch_level:-preview1}" elif [ "$rvm_ruby_version" = "1.8.6" ] ; then rvm_ruby_patch_level="${rvm_ruby_patch_level:-p383}" elif [ "$rvm_ruby_version" = "1.8.7" ] ; then rvm_ruby_patch_level="${rvm_ruby_patch_level:-p174}" elif [ "$rvm_ruby_version" = "1.8.5" ] ; then rvm_ruby_patch_level="${rvm_ruby_patch_level:-p115}" elif [ "$rvm_ruby_version" = "1.8.0" -o "$rvm_ruby_version" = "1.8.1" -o "$rvm_ruby_version" = "1.8.2" -o "$rvm_ruby_version" = "1.8.3" -o "$rvm_ruby_version" = "1.8.4" ] ; then unset rvm_ruby_patch_level else __rvm_log "fail" "Unknown ruby version: $rvm_ruby_version" fi ;; default|system) #noop? ;; *) __rvm_log "fail" "Ruby implementation '$rvm_ruby_interpreter' is not known." esac if [ ! -z "$rvm_ruby_rev" ] ; then if [ "$rvm_ruby_rev" = "head" -o "$rvm_ruby_rev" = "trunk" ] ; then rvm_ruby_patch_level="head" else rvm_ruby_patch_level="$rvm_ruby_rev" fi fi if [ ! -z "$rvm_ruby_interpreter" -a ! -z "$rvm_ruby_version" ] ; then rvm_major_version=$(echo $rvm_ruby_version | awk -F'.' '{ print $2 }') rvm_minor_version=$(echo $rvm_ruby_version | awk -F'.' '{ print $3 }') if [ -z "$rvm_gem_set_name" ] ; then rvm_gem_home="$rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version" else if [ ! -z "$rvm_gem_set_name_rm" -a -d $rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version-$rvm_gem_set_name ] ; then rm -rf $rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version-$rvm_gem_set_name/ if [ "$rvm_gem_set_name_rm" = "$rvm_gem_set_name" ] ; then unset rvm_gem_set_name ; fi else rvm_gem_home="$rvm_gem_path/$rvm_ruby_interpreter/$rvm_ruby_version-$rvm_gem_set_name" fi fi mkdir -p $rvm_gem_home if [ -z "$rvm_ruby_patch_level" ] ; then rvm_ruby_package_name="${rvm_ruby_package_name:-"$rvm_ruby_interpreter-$rvm_ruby_version"}" rvm_ruby_home="${rvm_ruby_home:-"$rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version"}" else rvm_ruby_package_name="${rvm_ruby_package_name:-"$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level"}" rvm_ruby_home="${rvm_ruby_home:-"$rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level"}" fi rvm_ruby_log_path="$rvm_log_path/$rvm_ruby_package_name" rvm_ruby_src_path="$rvm_source_path/$rvm_ruby_package_name" rvm_ruby_binary="$rvm_ruby_home/bin/ruby" rvm_ruby_irbrc="$rvm_ruby_home/.irbrc" rvm_selected=1 else unset rvm_selected fi } function __rvm_use { if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi if [ -z "$rvm_ruby_interpreter" ] ; then rvm_ruby_interpreter="default" ; fi if [ "$rvm_ruby_interpreter" = "default" -o "$rvm_ruby_interpreter" = "system" ] ; then unset GEM_HOME MY_RUBY_HOME IRBRC PATH="$rvm_default_path" ; export PATH if [ "$rvm_ruby_interpreter" = "default" -a -s $rvm_install_path/current ] ; then source $rvm_install_path/current fi else GEM_HOME=$rvm_gem_home ; export GEM_HOME MY_RUBY_HOME=$rvm_ruby_home ; export MY_RUBY_HOME IRBRC="$rvm_ruby_irbrc" ; export IRBRC # Install if not installed if [ ! -d $MY_RUBY_HOME ] ; then __rvm_log "warn" "$rvm_ruby_interpreter $rvm_ruby_version is not installed." __rvm_install-ruby $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level fi if [ ! -s "$rvm_ruby_irbrc" ] ; then rvm_irbrc_file=$(cat < "${rvm_ruby_package_name} > ", # default prompt :PROMPT_S => "${rvm_ruby_package_name}%l> ", # known continuation :PROMPT_C => "${rvm_ruby_package_name} > ", :PROMPT_N => "${rvm_ruby_package_name} ?> ", # unknown continuation :RETURN => " => %s \n", :AUTO_INDENT => true } @prompt_mode = :DEFAULT IRB.conf[:PROMPT][@prompt_mode] = @prompt IRB.conf[:PROMPT_MODE] = @prompt_mode Config ) if [ -s ~/.irbrc ] ; then cp ~/.irbrc $rvm_ruby_home/.irbrc fi echo "$rvm_irbrc_file" >> $rvm_ruby_home/.irbrc fi PATH="$MY_RUBY_HOME/bin:$GEM_HOME/bin:$rvm_install_path/bin:$rvm_default_path" ; export PATH rvm_prompt="$rvm_ruby_package_name" ; export rvm_prompt if [ ! -z "$rvm_set_prompt" -a ! -z "$PS1" ] ; then PS1="\033[0;32m${rvm_prompt}\033[0m:: ${rvm_default_ps1}" ; export PS1 fi if [ ! -z "$rvm_set_default" ] ; then RUBY_VERSION="$($MY_RUBY_HOME/bin/ruby -v | sed 's/^\(.*\) (.*$/\1/')" export GEM_HOME MY_RUBY_HOME RUBY_VERSION echo "PATH=$MY_RUBY_HOME/bin:$GEM_HOME/bin:$rvm_install_path/bin:$rvm_default_path ; export PATH" > $rvm_install_path/current for variable in rvm_prompt RUBY_VERSION GEM_HOME MY_RUBY_HOME ; do eval "export $variable" eval value=\$${variable} echo "${variable}='$value' ; export ${variable}" >> $rvm_install_path/current done fi fi } function __rvm_bin_scripts { if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi ruby_wrapper=$(cat <<-RubyWrapper #!/bin/bash GEM_HOME=$rvm_gem_home ; export GEM_HOME MY_RUBY_HOME=$rvm_ruby_home ; export MY_RUBY_HOME PATH=$rvm_ruby_home/bin:$rvm_gem_home/bin:$rvm_default_path ; export PATH exec "$rvm_ruby_binary" "\$@" RubyWrapper ) echo "$ruby_wrapper" > $rvm_bin_path/$rvm_ruby_package_name unset ruby_wrapper chmod +x $rvm_bin_path/$rvm_ruby_package_name } function __rvm_symlinks { # TODO: Account for the ruby wrapper script files mkdir -p ${rvm_install_path}/bin for release in `/bin/ls $rvm_install_path | grep 'ruby-'` ; do for binary in irb gem rdoc ri erb ; do if [ -x $rvm_install_path/$release/bin/$binary ] ; then ln -fs $rvm_install_path/$release/bin/$binary $rvm_install_path/bin/$binary-${release#ruby-} fi done done } function __rvm_list { if [ "$rvm_all" ] ; then svn list http://svn.ruby-lang.org/repos/ruby/tags/ | grep 'v1_[8|9]' | sed 's/^v1_//' | sed 's/\/$//' | awk -F'_' '{print "1."$1"."$2 " -l "$3}' | sed 's/p$//' echo "jruby 1.2.0" echo "jruby 1.3.0" echo "jruby 1.3.1" echo "jruby head" echo "rubinius head" echo "rbx head" echo "ree 20090610" else echo -e "\nruby:\n$(/bin/ls -l $rvm_install_path/ | awk '/ ruby-[1-2].*/ { print " - " $NF }')\n" echo -e "jruby:\n$(/bin/ls -l $rvm_install_path/ | awk '/jruby-.*/ { print " - " $NF }')\n" echo -e "ree:\n$(/bin/ls $rvm_install_path/ | awk '/ruby-enterprise-.*/ { print " - " $NF }')\n" echo -e "system:\n - ($($default_system_ruby -v))\n" fi } function __rvm_reset { PATH="$rvm_install_path/bin:$rvm_default_path" ; export PATH for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME rvm_prompt ; do unset $variable ; done rm -f $rvm_install_path/default* rm -f $rvm_install_path/current __rvm_select "system" } function __rvm_implode { while : ; do __rvm_log "warn" "Are you SURE you wish for rvm to implode? This will remove $rvm_install_path ? (type 'yes' or 'no')" read response if [ "$response" = "yes" ] ; then if [ -d $rvm_install_path ] ; then __rvm_log "info" "Hai! Removing $rvm_install_path" rm -rf $rvm_install_path/ else __rvm_log "info" "It appears that $rvm_install_path is already non existant." fi break elif [ "$response" = "no" ] ; then __rvm_log "info" "Cancelling implosion, no harm done :)" break fi done } function __rvm_gem-dir { if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi mkdir -p $rvm_gem_home echo $rvm_gem_home } function __rvm_src-dir { if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi if [ -z "$rvm_ruby_src_path" ] ; then __rvm_log "fail" "No source directory exists for the default implementation." else echo "$rvm_ruby_src_path" fi } # clones from source implementation/version to current function __rvm_gem-dup { if [ "$1" = "default" ] ; then rvm_source_gem_dir="$rvm_default_user_gem_path" elif [ "$1" = "system" ] ; then rvm_source_gem_dir="$rvm_default_system_gem_path" else rvm_source_gem_dir=${1:-$rvm_default_user_gem_path} # TODO: check for and remove trailing /gems fi if [ ! -z "$rvm_source_gem_dir" ] ; then for rvm_gem_name_version in `/bin/ls $rvm_source_gem_dir/gems` ; do rvm_gem_name=${rvm_gem_name_version%-*} rvm_gem_version=${rvm_gem_name_version##*-} if [ -d $GEM_HOME/gems/$rvm_gem_name_version ] ; then echo "$rvm_gem_name_version already installed." else __rvm_gi $rvm_source_gem_dir/cache/$rvm_gem_name-$rvm_gem_version.gem fi done unset rvm_gem_name_version rvm_gem_name rvm_gem_version else __rvm_log "fail" "Unknown $rvm_ruby_interpreter version: $rvm_ruby_version" fi } function __rvm_cache { rvm_cache_file="$rvm_config_path/cache" touch $rvm_cache_file key="$1" ; shift if [ -z "$key" ] ; then __rvm_log "fail" "__rvm_cache must be called with at least one argument: __rvm_cache key [value]" else if [ "$key" = "unset" -o "$key" = "delete" ] ; then sed -i~ "s/^$2=.*$//" $rvm_cache_file else value="$*" if [ -z "$value" ] ; then # get grep "^$key=" $rvm_cache_file | awk -F'=' '{print $2}' else # set if [ -z "$(grep "^$key=" $rvm_cache_file)" ] ; then # append echo "$key=$value" >> $rvm_cache_file else # overwrite sed -i~ "s/^$key=.*$/$key=$value/" $rvm_cache_file fi fi fi fi } function __rvm_cleanup-variables { unset rvm_selected rvm_action rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_irbrc_file rvm_ruby_irbrc rvm_source_path rvm_install_path rvm_debug rvm_prefix_path rvm_ruby_package_name rvm_gem_path rvm_command rvm_error_message IRBRC rvm_ruby_home rvm_ruby_binary rvm_gem_set_name rvm_delete_flag rvm_ruby_tag rvm_ruby_rev rvm_url rvm_ruby_make rvm_ruby_make_install rvm_config_path rvm_bin_path rvm_force rvm_set_prompt rvm_all } function __rvm_get-user-defaults { # NOW load defaults settings. TODO: root user loads /etc/rvmrc if [ -s ~/.rvmrc ] ; then source ~/.rvmrc ; fi } function __rvm_parse-args { while [ $# -gt 0 ] ; do rvm_token="$1" ; shift case "$rvm_token" in install|uninstall|path|info|setup|version|srcdir|list|symlinks|reset|debug|reload|usage|help|implode|update) rvm_action=$rvm_token ;; use) rvm_action=$rvm_token if [ "$1" = "default" ] ; then rvm_ruby_interpreter="system" ; shift elif [ -z "$1" ] ; then rvm_ruby_interpreter="system" fi ;; ruby|jruby|ree|macruby|rbx|rubinius|default|all) rvm_ruby_interpreter="$rvm_token" rvm_action="${rvm_action:-use}" ;; gemdir) rvm_action=$rvm_token if [ "$1" = "system" ] ; then rvm_ruby_interpreter="system" ; shift fi if [ "$1" = "user" ] ; then rvm_ruby_interpreter="user" ; shift fi rvm_ruby_interpreter="${rvm_ruby_interpreter:-current}" ;; gemdup) rvm_action=$rvm_token if [ -z "$1" ] ; then rvm_ruby_interpreter="default" elif [ "$1" = "system" ] ; then rvm_ruby_interpreter=$1 ; shift elif [ "$1" = "default" ] ; then rvm_ruby_interpreter=$1 ; shift else rvm_ruby_interpreter=$1 ; shift rvm_ruby_version=$2 ; shift fi ;; do|rubydo) rvm_action=$rvm_token temp=$(echo $1 | awk '{print substr($1, 0, 1)}') if [ "$temp" != "-" ] ; then if [ ! -z "$(echo $temp | grep '[0-9]')" ] ; then rvm_ruby_version=$(echo "$1" | tr ',' ' ') ; shift else rvm_ruby_version=$1 ; shift fi else unset rvm_ruby_version fi unset rvm_ruby_interpreter ;; 1.8|1.8.0|1.8.1|1.8.2|1.8.3|1.8.4|1.8.5|1.8.6|1.8.7|1.9|1.9.1|1.9.2) rvm_ruby_interpreter="ruby" rvm_ruby_version="$rvm_token" rvm_action="${rvm_action:-use}" ;; 1.2.0|1.3.1) rvm_ruby_interpreter="jruby" rvm_ruby_version="$rvm_token" rvm_action="${rvm_action:-use}" ;; -v|--version) if [ -z "$1" ] ; then rvm_action="version" else rvm_ruby_version="$1" fi shift ;; -t|--tag) rvm_ruby_tag="$1"; rvm_action="${rvm_action:-use}" shift ;; -r|--rev) rvm_ruby_rev="$1"; rvm_action="${rvm_action:-use}" shift ;; -b|--branch) rvm_ruby_rev="$1"; rvm_action="${rvm_action:-use}" shift ;; -P|--prefix) rvm_prefix_path="$1" ; shift ;; -B|--bin) rvm_bin_path="$1" ; shift ;; -S|--source) rvm_source_path="$1" ; shift ;; -A|--archive) rvm_archives_path="$1" ; shift ;; -G|--gems) rvm_gem_path="$1" ; shift ;; -C|--configure) if [ ! -z "$1" ] ; then rvm_ruby_configure="$(echo $1 | tr ',' ' ')" shift else rvm_action="error" rvm_error_message="--configure *must* be followed by configure flags." break; fi ;; -M|--make) rvm_ruby_make="$1" ; shift ;; -I|--make-install) rvm_ruby_make_install="$1" ; shift ;; -l|--level) rvm_ruby_patch_level="$1" ; shift ;; -n|--nice) rvm_niceness="$1" ; shift ;; -f|--file) rvm_ruby_args="$1" ; shift ;; -h|--help) rvm_action=help ; shift ;; -d|--default) rvm_set_default=1 ;; --head) rvm_ruby_rev="head" ;; --trace|--debug) rvm_debug=1 ;; --force) rvm_force=1 ;; --set-prompt) rvm_set_prompt=1 ;; --all) rvm_all=1 ; shift ;; -m|--gem-set) rvm_gem_set_name="$1" ; shift ;; --rm-gem-set) rvm_gem_set_name_rm="$1" ; shift ;; --jit) rvm_rubinius_jit="RBX_LLVM=1" ;; default|system) rvm_action="use" rvm_ruby_interpreter="system" ;; *) rvm_action="error" rvm_error_message="Unrecognized command line argument(s): '$rvm_token $*'" break; esac if [ ! -z "$rvm_ruby_args" -o ! -z "$rvm_error_message" ] ; then break; fi done if [ ! -z "$rvm_error_message" ] ; then popd 2> /dev/null ; return 1 ; fi if [ -z "$rvm_debug" ] ; then set +x ; else set -x ; fi } function rvm { __rvm_cleanup-variables __rvm_get-user-defaults __rvm_initialize __rvm_set-defaults __rvm_parse-args $* case "$rvm_action" in install) __rvm_install-ruby $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level ;; uninstall) __rvm_uninstall $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level ;; use) __rvm_use $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level ;; list) __rvm_list ;; gemdir) __rvm_gem-dir $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level ;; srcdir) __rvm_src-dir $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level ;; gemdup) __rvm_gem-dup $rvm_ruby_interpreter $rvm_ruby_version $rvm_ruby_patch_level ;; symlinks) __rvm_symlinks ;; version) __rvm_version ;; rubydo) if [ ! -z "$rvm_ruby_version" ] ; then rvm_ruby_versions=$(echo $rvm_ruby_version | tr ',' ' ') for rvm_ruby_version in $rvm_ruby_versions ; do temp=$(echo $rvm_ruby_version | awk '{print substr($1, 0, 1)}') if [ ! -z "$(echo $temp | grep '[0-9]')" ] ; then rvm_ruby_interpreter="ruby" else rvm_ruby_interpreter="$rvm_ruby_version" unset rvm_ruby_version fi unset temp __rvm_select $rvm_ruby_interpreter $rvm_ruby_version rvm_command="$rvm_ruby_binary $rvm_ruby_args" echo "$(basename $rvm_ruby_binary):" eval $rvm_command unset rvm_ruby_interpreter rvm_ruby_patch_level rvm_ruby_version rvm_ruby_package_name rvm_ruby_home rvm_ruby_irbrc rvm_ruby_binary done else # all rvm_ruby_versions=`/bin/ls $rvm_install_path/bin/ruby-*` for rvm_ruby_binary in $rvm_ruby_versions ; do if [ -x $rvm_ruby_binary ] ; then rvm_command="$rvm_ruby_binary $rvm_ruby_args" echo "$(basename $rvm_ruby_binary):" eval $rvm_command fi done fi ;; reset) __rvm_reset ;; # TODO: how can we use bin_path here for reload, default file? reload) source ~/.rvm/scripts/rvm ;; implode) __rvm_implode ;; update) if [ "$rvm_ruby_rev" = "head" ] ; then if [ -d $rvm_source_path/rvm/.git ] ; then cd $rvm_source_path/rvm/ && git pull origin master else cd $rvm_source_path && git clone git://github.com/wayneeseguin/rvm.git && cd rvm/ fi ./scripts/rvm-update else # TODO: rvm_install_path: gem install rvm --no-rdoc --no-ri -q && rvm-update && source ~/.rvm/scripts/rvm fi ;; error) __rvm_log "fail" "$rvm_error_message ( see: rvm usage )" ; popd 2> /dev/null ; return 1; ;; info|debug) __rvm_version cat <<-Info ruby: interpreter: "$(ruby -v | awk '{print $1}')" version: "$(ruby -v | awk '{print $2}')" date: "$(ruby -v | sed 's/^.*(\([0-9]\{4\}\(-[0-9][0-9]\)\{2\}\).*$/\1/')" platform: "$(ruby -v | sed 's/^.*\[//' | sed 's/\].*$//')" patchlevel: "$(ruby -v | sed 's/^.*(//' | sed 's/).*$//')" full_version: "$(ruby -v)" homes: gem: "${GEM_HOME:-'not set'}" ruby: "${MY_RUBY_HOME:-'not set'}" binaries: ruby: "$(which ruby)" irb: "$(which irb)" gem: "$(which gem)" environment: GEM_HOME: "$GEM_HOME" MY_RUBY_HOME: "$MY_RUBY_HOME" IRBRC: "$IRBRC" Info if [ "$rvm_action" = "debug" ] ; then __rvm_log "info" "PATH:$(echo $PATH | awk -F":" '{print $1":"$2":"$3":"$4":"$5}')" for file in .bash_profile .bashrc .zshrc ; do if [ -s $file ] ; then __rvm_log "debug" "~/$file:\n$(cat ~/$file | grep rvm)\n" fi done if [ -s $rvm_install_path/current ] ; then __rvm_log "debug" "$rvm_install_path/current:\n$($rvm_install_path/current)\n" fi if [ -e $rvm_install_path/bin/rvm ] ; then __rvm_log "debug" "rvm script in bin:\n$(ls -laht $rvm_install_path/bin/rvm)" fi fi return 0 ;; usage|help) __rvm_usage ;; *) if [ ! -z "$rvm_action" ] ; then __rvm_log "fail" "unknown action '$rvm_action'" else __rvm_usage fi return 1 esac if [ "$rvm_debug" = "1" ] ; then set +x ; unset rvm_debug ; fi } if [ -f ~/.rvm/current ] ; then source ~/.rvm/current ; fi # magic :)