scripts/gemsets in rvm-0.1.27 vs scripts/gemsets in rvm-0.1.29
- old
+ new
@@ -3,12 +3,13 @@
source $rvm_scripts_path/utility
source $rvm_scripts_path/selector
if [[ ! -z "$rvm_trace_flag" ]] ; then set -x ; export rvm_trace_flag ; fi
rvm_ruby_gem_home="${rvm_ruby_gem_home:-$GEM_HOME}"
-if [[ ! -d "$rvm_ruby_gem_home" ]] && which gem &> /dev/null ; then rvm_ruby_gem_home="$(gem env home)" ; fi
+if [[ ! -d "$rvm_ruby_gem_home" ]] && command -v gem > /dev/null 2>&1; then rvm_ruby_gem_home="$(gem env home)" ; fi
+
trap "if [[ -d $rvm_tmp_path/ ]] && [[ -s $rvm_tmp_path/$$ ]] ; then rm -f $rvm_tmp_path/$$ > /dev/null 2>&1 ; fi ; exit" 0 1 2 3 15
__rvm_gemset_name() {
__rvm_gemset_gemdir | awk -F${rvm_gemset_separator} '{print $2}'
}
@@ -67,16 +68,16 @@
$rvm_scripts_path/log "error" "A gemset name must be specified in order to delete a gems."
fi
}
__rvm_gemset_empty() {
- if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
+ if [[ -z "$rvm_ruby_gem_home" ]] ; then __rvm_select ; fi
gemdir="$rvm_ruby_gem_home"
if [[ -d "$gemdir" ]] && [[ "$gemdir" != '/' ]] && [[ ! -z "$rvm_force_flag" ]] ; then
cd $gemdir && rm -rf ./bin/* ./doc/* ./gems/* ./specifications/*
elif [[ -d "$gemdir" ]] ; then
- $rvm_scripts_path/log "warn" "Are you SURE you wish to remove the installed gemset for gemset '${rvm_gemset_separator}$rvm_gemset_name' ($gemdir)?"
+ $rvm_scripts_path/log "warn" "Are you SURE you wish to remove the installed gemset for gemset '$(basename $gemdir)' ($gemdir)?"
echo -n "(anything other than 'yes' will cancel) > "
read response
if [[ "yes" = "$response" ]] ; then
cd $gemdir && rm -rf ./bin/* ./doc/* ./gems/* ./specifications/*
else
@@ -95,18 +96,18 @@
$rvm_scripts_path/log "error" "Source and destination must be specified: 'rvm gemset copy X Y'"
fi
if [[ -z "$destination_ruby" ]] ; then
$rvm_scripts_path/log "error" "Source and destination must be specified: 'rvm gemset copy X Y'"
fi
- source_path="$($rvm_bin_path/rvm $source_ruby gem env gemdir | tail -n 1)"
- destination_path="$($rvm_bin_path/rvm $destination_ruby gem env gemdir | tail -n 1)"
-
+ source_path="$(rvm $source_ruby gem env gemdir | tail -n 1)"
+ destination_path="$(rvm $destination_ruby gem env gemdir | tail -n 1)"
if [[ -d "$source_path" ]] ; then
if [[ ! -d "$destination_path" ]] ; then mkdir -p $destination_path ; fi
$rvm_scripts_path/log "info" "Copying gemset from $source_ruby to $destination_ruby" ;
for dir in bin doc gems specifications ; do
- cp -Rf $source_path/$dir $destination_path/
+ mkdir -p "$destination_path/$dir"
+ cp -Rf "$source_path/$dir" "$destination_path/"
done
else
$rvm_scripts_path/log "error" "Gems directory does not exist for $source_path ($source_path)"
return 1
fi
@@ -224,10 +225,11 @@
}
# Install a gem
__rvm_gem_install() {
# First we parse the gem args to pick apart the pieces.
+
__rvm_parse_gems_args
# Now we determine if a .gem cache file is already installed
if [[ -z "$rvm_force_flag" ]] && [[ -f "${rvm_ruby_gem_home}/specifications/$(basename $gem_file_name)spec" ]] ; then
unset gem
@@ -272,20 +274,22 @@
if [[ ! -z "$gem" ]] ; then
# TODO: Set vars if fourth field is non-empty (means that there are conditional statements to execute in the gem install line.
if [[ "rvm_make_flags_flag" -eq 1 ]] ; then __rvm_make_flags ; fi
if [[ ! -z "$rvm_ruby_gem_home" ]] && [[ "$rvm_ruby_gem_home" != "$rvm_gems_path" ]] ; then
- command="GEM_HOME='$rvm_ruby_gem_home' GEM_PATH='$rvm_ruby_gem_home/bin:$rvm_gems_path/${rvm_ruby_string}${rvm_gemset_separator}global/bin' BUNDLE_PATH='${rvm_ruby_gem_home}' ${gem_prefix} gem install --ignore-dependencies $gems_args $rvm_gem_options $gem_postfix $vars"
+ #command="GEM_HOME='$rvm_ruby_gem_home' GEM_PATH='$rvm_ruby_gem_home/bin:$rvm_gems_path/${rvm_ruby_string}${rvm_gemset_separator}global/bin' BUNDLE_PATH='${rvm_ruby_gem_home}' ${gem_prefix} gem install --ignore-dependencies $gems_args $rvm_gem_options $gem_postfix $vars"
+ command="GEM_HOME='$rvm_ruby_gem_home' GEM_PATH='$rvm_ruby_gem_home/bin:$rvm_gems_path/${rvm_ruby_string}${rvm_gemset_separator}global/bin' BUNDLE_PATH='${rvm_ruby_gem_home}' ${gem_prefix} gem install $gems_args $rvm_gem_options $gem_postfix $vars"
else
+ #--ignore-dependencies
command="$gem_prefix gem install --ignore-dependencies $gems_args $rvm_gem_options -q $gem $gem_postfix $vars"
fi
- __rvm_run "gem.install" "$command" "$gem_name $gem_version is not installed, installing..."
+ __rvm_run "gem.install" "$command" "installing ${gem_name} ${gem_version}..."
result=$?
if [[ $result -eq 0 ]] ; then
- $rvm_scripts_path/log "info" "$gem_name $gem_version installed."
+ $rvm_scripts_path/log "info" "$gem_name $gem_version installed, output logged to:\n$rvm_path/log/$rvm_ruby_string/gem.install.log"
else
- $rvm_scripts_path/log "error" "$gem_name $gem_version failed to install, output has been logged to:\n$rvm_path/log/$rvm_ruby_string/gem.install.error.log"
+ $rvm_scripts_path/log "error" "$gem_name $gem_version failed to install, output logged to:\n$rvm_path/log/$rvm_ruby_string/gem.install.error.log"
fi
fi ; unset gem gem_prefix gem_name gem_version gem_file_name gem_postfix cache_file gem_file_name gem_string gem_action
return $result
}
@@ -305,10 +309,10 @@
fi
}
unset GEM_PATH
-if [[ -z "$(which gem 2>/dev/null)" ]] ; then
+if ! command -v gem > /dev/null ; then
$rvm_scripts_path/log "error" "'gem' was not found, cannot perform gem actions (Do you have an RVM ruby selected?)"
exit 1
fi
action="$(echo $* | awk '{print $1}')"