scripts/utility in rvm-0.1.39 vs scripts/utility in rvm-0.1.40
- old
+ new
@@ -61,10 +61,19 @@
fi
done
echo "$quoted_string" | sed -e 's/^ *//g' -e 's/ *$//g'
}
+__rvm_warn_on_rubyopt() {
+ if [[ -n "$RUBYOPT" ]]; then
+ $rvm_scripts_path/log "warn" "Please note: You have the RUBYOPT environment variable set and this may interfere with normal rvm operations. We sugges unsetting it."
+ return 1
+ else
+ return 0
+ fi
+}
+
__rvm_strings() {
unset results
for rvm_ruby_string in $(echo $rvm_ruby_args) ; do
#__rvm_ruby_string
if [[ $? -gt 0 ]] ; then
@@ -167,10 +176,61 @@
rvm $rvm_env_args use $1 && eval "$rvm_env_command"
)
unset rvm_env_args rvm_env_command
}
+# Returns the first 1.8.7-compatible (partly) ruby for use
+# with things like rbx etc which require a ruby be installed.
+__rvm_18_compat_ruby() {
+ rubies=""
+ for ruby_name in $(\ls $rvm_rubies_path); do
+ if [[ ! -L "$rvm_rubies_path/$ruby_name" ]] && $rvm_scripts_path/match "$ruby_name" '^(ruby-1.8.[[:digit:]]|rbx|ree)-'; then
+ rubies="$rubies $ruby_name"
+ fi
+ done; unset ruby_name
+ echo "$rubies" | sed 's/^ //' | tr ' ' '\n' | sort | tail -n1
+ unset rubies
+}
+
+__rvm_ensure_has_18_compat_ruby() {
+ if [[ -z "$(__rvm_18_compat_ruby)" ]]; then
+ # TODO: install currently doesn't return the correct status.
+ original_ruby="$(__rvm_environment_identifier)"
+ local compat_result=0
+ if ! $rvm_bin_path/rvm install 1.8.7; then
+ $rvm_scripts_path/log "fatal" "To proceed rvm requires a 1.8-compatible ruby is installed. We attempted to install 1.8.7 automatically but it failed."
+ $rvm_scripts_path/log "fatal" "Please install it manually (or a compatible alternative) to proceed."
+ compat_result=1
+ fi
+ __rvm_unset_ruby_variables
+ __rvm_become "$original_ruby"
+ unset original_ruby
+ return $compat_result
+ fi
+}
+
+__rvm_inherit_trace_flag() {
+ if [[ -n "$rvm_trace_flag" ]]; then
+ set -x
+ export rvm_trace_flag
+ fi
+}
+
+# Cleans up temp folders for a given prefix,
+# typically the current process id.
+__rvm_cleanup_temp_for() {
+ [[ -z "$1" ]] && return 1
+ if [[ -d "$rvm_tmp_path/" ]]; then
+ rm -rf "$rvm_tmp_path/$1"* >/dev/null 2>&1
+ fi
+ exit
+}
+
+__rvm_cleanup_temp_on_exit() {
+ trap "__rvm_cleanup_temp_for '$$'" 0 1 2 3 15
+}
+
__rvm_set_rvmrc() {
if [[ "$HOME" != "$(pwd)" ]] ; then
if [[ "$rvm_verbose_flag" -eq 1 ]] ; then flags="use " ; fi
if [[ -s .rvmrc ]] ; then
@@ -244,21 +304,21 @@
# rvm will refresh the stored information the next time it is called after reset.
__rvm_reset() {
PATH="$(echo $PATH | tr ':' '\n' | awk '$0 !~ /rvm/' | paste -sd : -)"
PATH="$rvm_bin_path:$PATH" ; export PATH
- for variable in RUBY_VERSION GEM_HOME BUNDLE_PATH MY_RUBY_HOME ; do unset $variable ; done
-
for flag in default passenger editor ; do rm -f "$rvm_bin_path"/${flag}_* ; done
+ unset flag
for file in system default ; do
- if [[ -f "$rvm_path/$file" ]] ; then rm -f $rvm_path/$file ; fi
- if [[ -f "$rvm_config_path/$file" ]] ; then rm -f $rvm_config_path/$file ; fi
- done
- rvm_ruby_interpreter="system"
- __rvm_select
+ rm -f "$rvm_path/$file" "$rvm_config_path/$file" "$rvm_environments_path/$file"
+ done; unset file
+ # Go back to a clean state.
+ __rvm_become "system"
+ __rvm_unset_ruby_variables
+
for system_config in system_ruby system_gem_path system_user_gem_path ; do
$rvm_scripts_path/db "$rvm_config_path/user" "$system_config" "delete"
done ; unset system_config variable
rm -f $rvm_bin_path/ruby $rvm_bin_path/gem $rvm_bin_path/rake $rvm_bin_path/irb $rvm_bin_path/default*
@@ -314,11 +374,11 @@
}
# Update rubygems or binscripts based on CLI selection.
__rvm_update() {
__rvm_pushpop $rvm_path
- if [[ "head" = "$rvm_ruby_revision" ]] || [[ ! -z "$rvm_self_flag" ]] || [[ "update" = "$rvm_action" ]] || [[ ! -z "$rvm_update_flag" ]] ; then
+ if [[ "$rvm_head_flag" == "1" ]] || [[ ! -z "$rvm_self_flag" ]] || [[ "update" = "$rvm_action" ]] || [[ ! -z "$rvm_update_flag" ]] ; then
__rvm_version
__rvm_update_rvm
fi
if [[ ! -z "$rvm_bin_flag" ]] ; then __rvm_bin_scripts ; fi
if [[ ! -z "$rvm_rubygems_flag" ]] ; then __rvm_rubygems_setup ; fi
@@ -331,22 +391,22 @@
# If --head was specified, update from git repository master branch.
__rvm_update_rvm() {
mkdir -p "$rvm_src_path"
__rvm_pushpop "$rvm_src_path"
- if [[ "head" = "$rvm_ruby_revision" ]] || [[ -z "$system_ruby" ]] ; then
+ if [[ "$rvm_head_flag" == "1" ]] ; then
if [[ -d "$rvm_src_path/rvm/.git" ]] ; then
builtin cd $rvm_src_path/rvm/ && git pull origin master && ./scripts/install
else
- builtin cd $rvm_src_path && git clone git://github.com/wayneeseguin/rvm.git && builtin cd rvm/ && ./install
+ builtin cd $rvm_src_path && git clone http://github.com/wayneeseguin/rvm.git && builtin cd rvm/ && ./scripts/install
fi
else
stable_version=$(curl -s http://rvm.beginrescueend.com/releases/stable-version.txt)
__rvm_run "fetch" "$rvm_scripts_path/fetch 'http://rvm.beginrescueend.com/releases/rvm-${stable_version}.tar.gz'" "fetching rvm-${stable_version}.tar.gz"
- __rvm_run "extract" "cat $rvm_archives_path/rvm-${stable_version}.tar.gz | gunzip | tar xf - -C $rvm_src_path" "Extracting $rvm_ruby_package_file ..."
+ __rvm_run "extract" "cat $rvm_archives_path/rvm-${stable_version}.tar.gz | gunzip | tar xf - -C $rvm_src_path" "Extracting rvm-${stable_version}.tar.gz ..."
__rvm_run "install" "builtin cd $rvm_src_path/rvm-${stable_version}/ ; ./install" "Installing rvm-${stable_version}..."
fi
__rvm_pushpop
@@ -532,10 +592,18 @@
rvm_ruby_gem_path="$rvm_ruby_gem_home:$rvm_ruby_global_gems_path"
# Ensure that the ruby gem home exists.
mkdir -p "$rvm_ruby_gem_home"
+ if [[ -n "$rvm_ruby_gem_home" ]] && echo "$rvm_ruby_gem_home" | grep -q 'rvm'; then
+ if __rvm_using_gemset_globalcache && [[ ! -L "$rvm_ruby_gem_home/cache" ]]; then
+ mv "$rvm_ruby_gem_home/cache/"*.gem "$rvm_gems_cache_path/" 2>/dev/null
+ rm -rf "$rvm_ruby_gem_home/cache"
+ ln -nfs "$rvm_gems_cache_path" "$rvm_ruby_gem_home/cache"
+ fi
+ fi
+
export rvm_ruby_gem_path rvm_ruby_gem_home
}
# Use a gemset specified by 'rvm_ruby_gem_home'
__rvm_gemset_use() {
@@ -635,9 +703,21 @@
mkdir -p "$directory_name"
# Install the default wrappers.
$rvm_scripts_path/wrapper "$environment_identifier" &> /dev/null
fi
unset rvm_creating_default_wrappers directory_name
+ fi
+}
+
+__rvm_using_gemset_globalcache() {
+ $rvm_scripts_path/db "$rvm_config_path/user" "use_gemset_globalcache" | grep -q '^true$'
+}
+
+__rvm_current_gemcache_dir() {
+ if __rvm_using_gemset_globalcache; then
+ echo "$rvm_gems_cache_path"
+ else
+ echo "${rvm_ruby_gem_home:-"$GEM_HOME"}/cache"
fi
}
__rvm_Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything() {
for index in {1..750} ; do perl -e 'sleep 0.2'; echo -n '.' ; done ; printf "%d" 0x2A ; echo