rvm 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,42 +1,66 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  if [[ ${rvm_ignore_rvmrc:-0} -eq 0 ]]; then
4
+
4
5
  for rvmrc in /etc/rvmrc "$HOME/.rvmrc" ; do
6
+
5
7
  if [[ -f "$rvmrc" ]] ; then
8
+
6
9
  if grep -q '^\s*rvm .*$' "$rvmrc" ; then
10
+
7
11
  printf "\n Error:
8
12
  $rvmrc is for rvm settings only.
9
13
  rvm CLI may NOT be called from within $rvmrc.
10
14
  Skipping the loading of $rvmrc
11
15
  "
12
16
  exit 1
17
+
13
18
  else
19
+
14
20
  source "$rvmrc"
21
+
15
22
  fi
23
+
16
24
  fi
25
+
17
26
  done
27
+
18
28
  fi
19
29
 
20
30
  # Setup default sandbox value. See scripts/rvm for origin.
21
31
  if [[ ${rvm_selfcontained:-0} -eq 0 ]]; then
32
+
22
33
  if [[ "root" = "$(whoami)" ]] || [[ -n "$rvm_prefix" && "$rvm_prefix" != "$HOME"/* ]]; then
34
+
23
35
  rvm_selfcontained=0
36
+
24
37
  else
38
+
25
39
  rvm_selfcontained=1
40
+
26
41
  fi
42
+
27
43
  fi
28
44
 
29
45
  if [[ -z "${rvm_prefix:-""}" ]] ; then
46
+
30
47
  if [[ ${rvm_selfcontained:-0} -eq 0 ]] ; then
48
+
31
49
  rvm_prefix="/usr/local/"
50
+
32
51
  else
52
+
33
53
  rvm_prefix="$HOME/."
54
+
34
55
  fi
56
+
35
57
  fi
36
58
 
37
59
  # Fix rvm_prefix changes.
38
60
  echo "$rvm_prefix" | grep -vq '\(\/\|\.\)$' && [[ -d "$rvm_prefix/rvm/scripts" ]]
61
+
39
62
  rvm_prefix_needs_trailing_slash="$?"
63
+
40
64
  if [[ "$rvm_prefix" = "/usr/local" || "$rvm_prefix_needs_trailing_slash" = "0" ]]; then
41
65
  rvm_prefix="$rvm_prefix/"
42
66
  fi
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 0
4
- :patch: 8
4
+ :patch: 9
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rvm}
8
- s.version = "1.0.8"
8
+ s.version = "1.0.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Wayne E. Seguin"]
12
- s.date = %q{2010-09-14}
12
+ s.date = %q{2010-09-15}
13
13
  s.default_executable = %q{rvm-install}
14
14
  s.description = %q{Manages Ruby interpreter environments and switching between them.}
15
15
  s.email = %q{wayneeseguin@gmail.com}
@@ -78,45 +78,84 @@ alias_delete() {
78
78
  }
79
79
 
80
80
  alias_create() {
81
- rvm_environment_identifier="${rvm_environment_identifier:-""}"
81
+
82
82
  alias_name="${alias_name:-""}"
83
+
83
84
  rvm_ruby_string="${rvm_ruby_string:-""}"
84
85
 
85
- if alias_conflicts_with_ruby "$alias_name"; then
86
+ if [[ "default" != "$alias_name" ]] && alias_conflicts_with_ruby "$alias_name"; then
86
87
  # Force it to an empty alias name to trigger the usage.
87
88
  alias_name=""
88
89
  fi
89
90
 
90
- if [[ -z "$rvm_environment_identifier" ]] || [[ -z "$alias_name" ]] ; then
91
- "$rvm_path/scripts"/log "error" "\nusage: 'rvm alias [alias_name] [ruby_string]'\n"
91
+ if [[ -z "${rvm_environment_identifier:-""}" || -z "$alias_name" ]] ; then
92
+
93
+ "$rvm_path/scripts"/log "error" \
94
+ "\nusage: 'rvm alias [alias_name] [ruby_string]'\n"
95
+
92
96
  result=1
93
97
  else
98
+
99
+ if [[ "default" = "$alias_name" ]] ; then
100
+ rvm_alias=""
101
+ fi
102
+
94
103
  if [[ -z "$rvm_alias" ]] ; then
104
+
95
105
  rvm_ruby_string="$rvm_environment_identifier"
106
+
96
107
  if [[ -z "$rvm_alias_expanded" ]]; then
108
+
97
109
  rvm_expanding_aliases=1
110
+
98
111
  __rvm_become
112
+
99
113
  unset rvm_expanding_aliases
114
+
100
115
  else
116
+
101
117
  rvm_ruby_string="$rvm_environment_identifier"
118
+
102
119
  fi
120
+
103
121
  if [[ -z "$rvm_ruby_string" ]]; then
104
- "$rvm_path/scripts"/log "error" "\nUnknown ruby string '$rvm_ruby_string' specified\n"
122
+
123
+ "$rvm_path/scripts"/log "error" \
124
+ "\nUnknown ruby string '$rvm_ruby_string' specified\n"
125
+
105
126
  result=1
106
- return
127
+
128
+ return $result
107
129
  fi
108
- final_environment_identifier="$(__rvm_environment_identifier)"
109
- "$rvm_path/scripts"/log "info" "Creating alias $alias_name for $final_environment_identifier."
130
+
131
+ final_environment_identifier="${rvm_environment_identifier:-$(__rvm_environment_identifier)}"
132
+
133
+ "$rvm_path/scripts"/log "info" \
134
+ "Creating alias $alias_name for $final_environment_identifier."
135
+
110
136
  ln -nfs "$rvm_path/rubies/$rvm_ruby_string" "$rvm_path/rubies/$alias_name"
111
- "$rvm_path/scripts"/log "info" "Recording alias $alias_name for $final_environment_identifier."
137
+
138
+ "$rvm_path/scripts"/log "info" \
139
+ "Recording alias $alias_name for $final_environment_identifier."
140
+
112
141
  "$rvm_path/scripts"/db "$rvm_path/config/alias" "$alias_name" "$final_environment_identifier"
142
+
113
143
  else
144
+
114
145
  if [[ -d "$rvm_path/rubies/$alias_name" ]] ; then
115
- "$rvm_path/scripts"/log "error" "\n$rvm_path/rubies/$alias_name is taken and is *not* able to be an alias name.\n"
146
+
147
+ "$rvm_path/scripts"/log "error" \
148
+ "\n$rvm_path/rubies/$alias_name is taken and is *not* able to be an alias name.\n"
149
+
116
150
  result=1
151
+
117
152
  else
118
- "$rvm_path/scripts"/log "error" "\n$rvm_path/rubies/$alias_name is already aliased.\n"
153
+
154
+ "$rvm_path/scripts"/log "error" \
155
+ "\n$rvm_path/rubies/$alias_name is already aliased.\n"
156
+
119
157
  result=1
158
+
120
159
  fi
121
160
  fi
122
161
  fi
@@ -124,15 +163,13 @@ alias_create() {
124
163
 
125
164
  alias_list() {
126
165
 
127
- local item
166
+ local item items
128
167
 
129
- for item in "$rvm_path/rubies/"* ; do
168
+ items=($(cd "$rvm_path/rubies" ; find . -maxdepth 1 -mindepth 1 -type l | sed -e 's#./##'))
130
169
 
131
- if [[ -L "$item" ]] ; then
170
+ for item in "${items[@]}" ; do
132
171
 
133
- echo "$(basename "$item") => $("$rvm_path/scripts"/db "$rvm_path/config/alias" "$(basename "$item")")"
134
-
135
- fi
172
+ echo "$(basename "$item") => $("$rvm_path/scripts"/db "$rvm_path/config/alias" "$(basename "$item")")"
136
173
 
137
174
  done
138
175
 
@@ -154,21 +191,33 @@ else
154
191
  gemset_name=""
155
192
  fi
156
193
 
157
- if [[ ! -z "$alias_name" ]] ; then
194
+ if [[ -n "$alias_name" ]] ; then
158
195
  rvm_alias="$("$rvm_path/scripts/db" "$rvm_path/config/alias" "$alias_name")"
159
196
  fi
160
197
 
161
198
  if [[ "$action" = "delete" ]] ; then
199
+
162
200
  alias_delete
201
+
163
202
  elif [[ "$action" = "create" ]] ; then
203
+
164
204
  alias_create
205
+
165
206
  elif [[ "$action" = "list" ]] ; then
207
+
166
208
  alias_list
209
+
167
210
  elif [[ "$action" = "show" ]]; then
211
+
168
212
  alias_show
213
+
214
+
169
215
  elif [[ "$action" = "help" ]]; then
216
+
170
217
  usage
218
+
171
219
  else
220
+
172
221
  usage
173
222
  exit 1
174
223
  fi
@@ -6,10 +6,17 @@
6
6
  # Load the general scripts.
7
7
  # Use rvm_base_except="" to override the except.
8
8
  for script_name in initialize utility selector ; do
9
+
9
10
  if echo "${rvm_base_except:-""}" | \grep -vq "$script_name" ; then
11
+
10
12
  source "$rvm_path/scripts/$script_name"
13
+
11
14
  fi
12
- done ; unset script_name rvm_base_except
15
+
16
+ done
17
+
18
+ unset script_name rvm_base_except
19
+
13
20
 
14
21
  #for option in errexit noclobber nounset ; do
15
22
  # set -o $option
@@ -31,5 +38,8 @@ else
31
38
  __array_start=0
32
39
  fi
33
40
 
41
+ export BUNDLE_PATH GEM_HOME GEM_PATH rvm_action rvm_alias_expanded rvm_archflags rvm_archive_extension rvm_bin_flag rvm_bin_path rvm_clang_flag rvm_configure_flags rvm_debug_flag rvm_default_flag rvm_delete_flag rvm_docs_type rvm_dump_environment_flag rvm_error_message rvm_expanding_aliases rvm_file_name rvm_gemdir_flag rvm_gemset_name rvm_gemstone_package_file rvm_gemstone_url rvm_head_flag rvm_hook rvm_install_arguments rvm_install_on_use_flag rvm_interactive_flag rvm_llvm_flag rvm_loaded_flag rvm_make_flags rvm_niceness rvm_nightly_flag rvm_only_path_flag rvm_parse_break rvm_patch_names rvm_patch_original_pwd rvm_pretty_print_flag rvm_prior_cc rvm_proxy rvm_quiet_flag rvm_ree_options rvm_reload_flag rvm_remove_flag rvm_ruby_alias rvm_ruby_aliases rvm_ruby_args rvm_ruby_binary rvm_ruby_bits rvm_ruby_configure rvm_ruby_file rvm_ruby_gem_home rvm_ruby_gem_path rvm_ruby_global_gems_path rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_load_path rvm_ruby_major_version rvm_ruby_make rvm_ruby_make_install rvm_ruby_minor_version rvm_ruby_mode rvm_ruby_name rvm_ruby_package_file rvm_ruby_package_name rvm_ruby_patch rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_require rvm_ruby_revision rvm_ruby_selected_flag rvm_ruby_sha rvm_ruby_string rvm_ruby_strings rvm_ruby_tag rvm_ruby_url rvm_ruby_user_tag rvm_ruby_version rvm_script_name rvm_sdk rvm_silent_flag rvm_sticky_flag rvm_system_flag rvm_token rvm_trace_flag rvm_use_flag rvm_user_flag rvm_verbose_flag rvm_wrapper_name
42
+
43
+
34
44
  # Cleanup tmp on exit.
35
45
  trap "__rvm_cleanup_temp_for '$$'" 0 1 2 3 15
@@ -84,7 +84,7 @@ __rvm_parse_args() {
84
84
  gemset)
85
85
  rvm_action=$rvm_token
86
86
 
87
- rvm_ruby_gem_home="$GEM_HOME"
87
+ rvm_ruby_gem_home="${GEM_HOME:-""}"
88
88
 
89
89
  if [[ -z "$next_token" ]] ; then
90
90
  rvm_ruby_args="help"
@@ -397,25 +397,24 @@ __rvm_parse_args() {
397
397
  ;;
398
398
 
399
399
  --trace|--debug)
400
- local option=""
400
+ local option
401
401
 
402
402
  export rvm_debug_flag=1
403
403
 
404
- for option in verbose noclobber nounset ; do
405
- set -o $option
406
- done
404
+ set -o verbose
405
+ set -o noclobber
406
+ set -o nounset
407
407
 
408
408
  if [[ -z "${ZSH_VERSION:-""}" ]] ; then
409
409
  set -o errtrace
410
410
  fi
411
411
 
412
412
  # errexit pipefail
413
-
414
413
  if [[ "$rvm_token" = "--trace" ]] ; then
415
414
 
416
415
  export rvm_trace_flag=1
417
416
 
418
- set -o xtrace
417
+ #set -o xtrace
419
418
 
420
419
  if [[ -z "${ZSH_VERSION:-""}" ]] ; then
421
420
  export PS4='-[${BASH_SOURCE}] : ${LINENO} : ${FUNCNAME[0]:+${FUNCNAME[0]}() > }'
@@ -423,7 +422,6 @@ __rvm_parse_args() {
423
422
  fi
424
423
  ;;
425
424
 
426
-
427
425
  --proxy)
428
426
  rvm_proxy="$next_token"
429
427
  if [[ $# -gt 0 ]] ; then next_token="$1" ; shift ; else next_token="" ; fi
@@ -579,8 +577,6 @@ __rvm_parse_args() {
579
577
  if [[ ${rvm_parse_break:-0} -eq 1 || -n "${rvm_error_message:-""}" ]] ; then break ; fi
580
578
  done
581
579
 
582
- export rvm_head_flag $(env | awk -F= -v ORS=' ' '/^rvm_/{print $1}')
583
-
584
580
  # Empty args list.
585
581
  while [[ $# -gt 0 ]] ; do shift ; done
586
582
 
@@ -632,7 +628,7 @@ rvm() {
632
628
 
633
629
  result=0
634
630
 
635
- export BUNDLE_PATH GEM_HOME GEM_PATH $(env | awk -F= -v ORS=' ' '/^rvm_/{print $1}')
631
+ export BUNDLE_PATH GEM_HOME GEM_PATH rvm_action rvm_archflags rvm_bin_flag rvm_bin_path rvm_clang_flag rvm_configure_flags rvm_debug_flag rvm_delete_flag rvm_docs_type rvm_dump_environment_flag rvm_error_message rvm_file_name rvm_gemdir_flag rvm_gemset_name rvm_head_flag rvm_install_arguments rvm_install_on_use_flag rvm_interactive_flag rvm_llvm_flag rvm_loaded_flag rvm_make_flags rvm_niceness rvm_only_path_flag rvm_parse_break rvm_patch_names rvm_patch_original_pwd rvm_pretty_print_flag rvm_prior_cc rvm_proxy rvm_quiet_flag rvm_ree_options rvm_reload_flag rvm_remove_flag rvm_ruby_alias rvm_ruby_aliases rvm_ruby_args rvm_ruby_file rvm_ruby_gem_home rvm_ruby_interpreter rvm_ruby_load_path rvm_ruby_make rvm_ruby_make_install rvm_ruby_patch_level rvm_ruby_repo_url rvm_ruby_require rvm_ruby_string rvm_ruby_strings rvm_ruby_version rvm_script_name rvm_sdk rvm_silent_flag rvm_system_flag rvm_token rvm_trace_flag rvm_use_flag rvm_user_flag rvm_verbose_flag rvm_wrapper_name
636
632
 
637
633
  case "$rvm_action" in
638
634
  use) __rvm_use ;;
@@ -704,7 +700,7 @@ rvm() {
704
700
  if [[ ${rvm_delete_flag:-0} -eq 1 ]] ; then
705
701
  gem_prefix="$(echo "${GEM_HOME:-""}" | sed 's/'${rvm_gemset_separator:-"@"}'.*$//')"
706
702
 
707
- if [[ -n "${GEM_HOME:-""}" && "$GEM_HOME" = "${gem_prefix}${rvm_gemset_separator:-"@"}${rvm_gemset_name}" ]] ; then
703
+ if [[ "${GEM_HOME:-""}" = "${gem_prefix}${rvm_gemset_separator:-"@"}${rvm_gemset_name}" ]] ; then
708
704
  rvm_ruby_gem_home="$gem_prefix"
709
705
  GEM_HOME="$rvm_ruby_gem_home"
710
706
  BUNDLE_PATH="$rvm_ruby_gem_home"
@@ -765,6 +761,6 @@ rvm() {
765
761
  rvm_trace_flag=0
766
762
  fi
767
763
 
768
- return $result
764
+ return ${result:-0}
769
765
  }
770
766
 
data/scripts/db CHANGED
@@ -1,41 +1,86 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  usage() {
4
- printf "\nUsage:\n" >&2
5
- printf "\n $rvm_path/scripts/db database_file {{key}} {{value}} # set" >&2
6
- printf "\n $rvm_path/scripts/db database_file {{key}} # get" >&2
7
- printf "\n $rvm_path/scripts/db database_file {{key}} unset # unset\n\n" >&2
4
+ printf "
5
+
6
+ Usage:
7
+
8
+ db database_file {{key}} {{value}} # set
9
+ db database_file {{key}} # get
10
+ db database_file {{key}} unset # unset
11
+
12
+ " >&2
8
13
  }
9
14
 
10
15
  if [[ -f "$1" ]] ; then
16
+
11
17
  database_file="$1" ; shift
18
+
12
19
  if [[ ! -f "$database_file" ]] ; then
13
- \mkdir -p $(dirname $database_file)
14
- \touch $database_file
20
+
21
+ directory=$(dirname "$database_file")
22
+
23
+ if [[ ! -d "$directory" ]] ; then
24
+ mkdir -p "$directory"
25
+ fi
26
+
27
+ touch "$database_file"
28
+
15
29
  fi
30
+
16
31
  else
32
+
17
33
  printf "\n\nDatabase file $1 does not exist.\n\n" >&2
34
+
18
35
  exit 1
36
+
19
37
  fi
20
38
 
21
39
  key="$1" ; shift
40
+
22
41
  if [[ -z "$key" ]] ; then
42
+
23
43
  usage
44
+
24
45
  exit 1
46
+
25
47
  else
48
+
26
49
  value="$*"
27
- if [[ "unset" = "$value" ]] || [[ "delete" = "$value" ]] ; then
28
- sed -i.tmp -e "s#^$key=.*\$##" -e '/^$/d' $database_file
50
+
51
+ if [[ "unset" = "$value" || "delete" = "$value" ]] ; then
52
+
53
+ sed -e "s#^$key=.*\$##" -e '/^$/d' "$database_file" > "$database_file.new"
54
+
55
+ mv "$database_file.new" "$database_file"
56
+
29
57
  else
58
+
30
59
  if [[ -z "$value" ]] ; then # get
31
- awk -F= '/^'"$key"'=/' $database_file | sed -e "s#^$key=##" -e '/^$/d'
60
+
61
+ awk -F= '/^'"$key"'=/' "$database_file" | sed -e "s#^$key=##" -e '/^$/d'
62
+
32
63
  else # set
33
- if [[ -z "$(awk -F= "/^'"$key"'=/{print $2}" $database_file)" ]] ; then # append
34
- echo "$key=$value" >> $database_file
64
+
65
+ sed -e "s#^$key=.*\$##" -e '/^$/d' "$database_file" > "$database_file.new"
66
+
67
+ mv "$database_file.new" "$database_file"
68
+
69
+ if [[ -z "$(awk -F= "/^'"$key"'=/{print $2}" "$database_file")" ]] ; then # append
70
+
71
+ echo "$key=$value" >> "$database_file"
72
+
35
73
  else # overwrite
36
- sed -i.tmp "s#^$key=.*\$#$key=$value#" $database_file
74
+
75
+ sed -i.tmp "s#^$key=.*\$#$key=$value#" "$database_file" > "$database_file.new"
76
+
77
+ mv "$database_file.new" "$database_file"
78
+
37
79
  fi
80
+
38
81
  fi
82
+
39
83
  fi
84
+
40
85
  fi
41
86
 
@@ -24,21 +24,30 @@ usage() {
24
24
  }
25
25
 
26
26
  gemset_update() {
27
+
27
28
  if [[ -z "$rvm_ruby_strings" ]]; then
29
+
28
30
  "$rvm_path/scripts/log" "info" "Running gem update for all rubies and gemsets."
29
31
 
30
32
  rvm_ruby_strings="$(builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ; find . -maxdepth 1 -mindepth 1 -type d -print 2>/dev/null | grep -v '^\(doc\|cache\|@\|system\)' | \tr '\n' ',')"
33
+
31
34
  rvm_ruby_strings="${rvm_ruby_strings/%,}"
35
+
32
36
  rvm_ruby_strings="${rvm_ruby_strings//.\/}"
37
+
33
38
  else
34
39
  "$rvm_path/scripts/log" "info" "Running gem update for the specified rubies."
35
40
  fi
41
+
36
42
  export rvm_ruby_strings
43
+
37
44
  "$rvm_path/scripts/set" "gem" "update"
45
+
38
46
  return $?
39
47
  }
40
48
 
41
49
  gemset_globalcache() {
50
+
42
51
  local gc_status globalcache_enabled directories directory_name full_directory_path directory_name
43
52
 
44
53
  if [[ "$1" == "enabled" ]]; then
@@ -46,6 +55,7 @@ gemset_globalcache() {
46
55
  __rvm_using_gemset_globalcache
47
56
 
48
57
  globalcache_enabled=$?
58
+
49
59
  gc_status="Unknown"
50
60
 
51
61
  if [[ $globalcache_enabled -eq 0 ]]; then
@@ -54,13 +64,15 @@ gemset_globalcache() {
54
64
  gc_status="Disabled"
55
65
  fi
56
66
 
57
- "$rvm_path/scripts/log" "info" "Gemset global cache is currently: $gc_status"
67
+ "$rvm_path/scripts/log" "info" \
68
+ "Gemset global cache is currently: $gc_status"
58
69
 
59
70
  return "$globalcache_enabled"
60
71
 
61
72
  elif [[ "$1" == "disable" ]]; then
62
73
 
63
- "$rvm_path/scripts/log" "info" "Removing the global cache (note: this will empty the caches)"
74
+ "$rvm_path/scripts/log" "info" \
75
+ "Removing the global cache (note: this will empty the caches)"
64
76
 
65
77
  directories=($(builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ; find . -maxdepth 1 -mindepth 1 -type d -print))
66
78
 
@@ -70,7 +82,8 @@ gemset_globalcache() {
70
82
 
71
83
  if [[ -L "$current_cache_path" && "$(readlink "$current_cache_path")" == "$rvm_gems_cache_path" ]]; then
72
84
 
73
- "$rvm_path/scripts/log" "info" "Reverting the gem cache for $directory_name to an empty directory."
85
+ "$rvm_path/scripts/log" "info" \
86
+ "Reverting the gem cache for $directory_name to an empty directory."
74
87
 
75
88
  rm -f "$current_cache_path" 2>/dev/null
76
89
 
@@ -82,7 +95,8 @@ gemset_globalcache() {
82
95
 
83
96
  elif [[ "$1" == "enable" ]]; then
84
97
 
85
- "$rvm_path/scripts/log" "info" "Enabling global cache for gems."
98
+ "$rvm_path/scripts/log" "info" \
99
+ "Enabling global cache for gems."
86
100
 
87
101
  mkdir -p "$rvm_gems_cache_path"
88
102
 
@@ -440,14 +454,22 @@ gemset_export() {
440
454
 
441
455
  gemset_import() {
442
456
 
457
+ unset -f gem
458
+
443
459
  if [[ -n "${rvm_ruby_gem_home:-""}" ]] ; then
444
460
  export GEM_HOME="$rvm_ruby_gem_home"
445
- export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin"
461
+ export GEM_PATH="$rvm_ruby_gem_home"
446
462
  export BUNDLE_PATH="$rvm_ruby_gem_home"
463
+ else
464
+ rvm_ruby_gem_home=${GEM_HOME:-$(gem env gemdir)}
447
465
  fi
448
466
 
449
- rvm_file_name="${gems_args}"
467
+ #rvm_gemset_name="${gems_args//.gem*/}"
468
+ #rvm_gemset_name="${gems_args// /}"
450
469
 
470
+ rvm_file_name="${gems_args// /}"
471
+
472
+ # TODO: this could likely be better with find
451
473
  if [[ -s "${rvm_file_name%.gems*}.gems" ]] ; then
452
474
  rvm_file_name="${rvm_file_name%.gems*}.gems"
453
475
 
@@ -468,7 +490,13 @@ gemset_import() {
468
490
  return 1
469
491
  fi
470
492
 
471
- mkdir -p "$rvm_gems_cache_path" # Ensure the base cache dir is initialized.
493
+ if [[ ! -d "$rvm_ruby_gem_home/specifications/" ]] ; then
494
+ mkdir -p "$rvm_ruby_gem_home/specifications/"
495
+ fi
496
+
497
+ if [[ ! -d "$rvm_gems_cache_path" ]] ; then
498
+ mkdir -p "$rvm_gems_cache_path" # Ensure the base cache dir is initialized.
499
+ fi
472
500
 
473
501
  if [[ -s "$rvm_file_name" ]] ; then
474
502
 
@@ -537,7 +565,7 @@ __rvm_parse_gems_args() {
537
565
  # Install a gem
538
566
  gem_install() {
539
567
 
540
- local result gem gem_prefix gem_name gem_version gem_file_name gem_postfix cache_file gem_file_name gem_string gem_action
568
+ local gem gem_prefix gem_name gem_version gem_file_name gem_postfix cache_file gem_file_name gem_string gem_action
541
569
 
542
570
  result=0
543
571
 
@@ -608,15 +636,17 @@ gem_install() {
608
636
 
609
637
  if [[ -n "$rvm_ruby_gem_home" && "$rvm_ruby_gem_home" != "${rvm_gems_path:-"$rvm_path/gems"}" ]] ; then
610
638
 
611
- command="GEM_HOME='$rvm_ruby_gem_home' GEM_PATH='$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin' BUNDLE_PATH='${rvm_ruby_gem_home}' ${gem_prefix} command gem install $gems_args $rvm_gem_options $gem_postfix $vars"
639
+ command="GEM_HOME='$rvm_ruby_gem_home' GEM_PATH='$rvm_ruby_gem_home' BUNDLE_PATH='${rvm_ruby_gem_home}' $gem_prefix gem install $gems_args $rvm_gem_options $gem_postfix $vars"
612
640
 
613
641
  else
614
642
 
615
643
  #--ignore-dependencies
616
- command="$gem_prefix command gem install --ignore-dependencies $gems_args $rvm_gem_options -q $gem $gem_postfix $vars"
644
+ command="$gem_prefix gem install --ignore-dependencies $gems_args $rvm_gem_options -q $gem $gem_postfix $vars"
617
645
 
618
646
  fi
619
647
 
648
+ unset -f gem
649
+
620
650
  __rvm_run "gem.install" "$command" "installing ${gem_name} ${gem_version}..."
621
651
  result=$?
622
652
 
@@ -717,37 +747,52 @@ gemset_pristine() {
717
747
  # Loads the default gemsets for the current interpreter and gemset.
718
748
  gemset_initial() {
719
749
 
750
+ local gemsets gemset path paths
751
+
752
+ rvm_gemsets_path="${rvm_gemsets_path:-"$rvm_path/gemsets"}"
753
+
720
754
  "$rvm_path/scripts/log" "info" \
721
755
  "Importing initial gemsets for $(__rvm_environment_identifier)."
722
756
 
723
- mkdir -p "$rvm_path/gemsets/${rvm_ruby_string//-//}" 2>/dev/null
757
+ if [[ ! -d "$rvm_gemsets_path/${rvm_ruby_string//-/\/}" ]] ; then
758
+ mkdir -p "$rvm_gemsets_path/${rvm_ruby_string//-/\/}" 2>/dev/null
759
+ fi
724
760
 
725
- for gemsets_path in $(__rvm_ruby_string_paths_under "$rvm_path/gemsets") ; do
761
+ paths=($(__rvm_ruby_string_paths_under "$rvm_gemsets_path"))
726
762
 
727
- # TODO: This can be condensed.
728
- if [[ -d "$gemsets_path" ]] ; then
763
+ echo "paths: ${paths[@]}"
764
+
765
+ for path in "${paths[@]}" ; do
766
+
767
+ if [[ -n "$rvm_gemset_name" ]] ; then
768
+
769
+ if [[ -s "${rvm_gemset_name}.gems" ]] ; then
770
+
771
+ ( gems_args="${rvm_gemset_name}.gems" ; gemset_import )
729
772
 
730
- if [[ -n "$rvm_gemset_name" && -s "${gemsets_path}/${rvm_gemset_name}.gems" ]] ; then
731
- (
732
- rvm --create "$rvm_ruby_string"
733
- "$rvm_path/scripts/gemsets" import "${gemsets_path}/${rvm_gemset_name}.gems"
734
- )
735
773
  fi
736
774
 
737
- if [[ -s "${gemsets_path}/default.gems" ]] ; then
738
- (
739
- rvm --create "$rvm_ruby_string"
740
- "$rvm_path/scripts/gemsets" import "$gemsets_path/default.gems"
741
- )
775
+ else
776
+
777
+ if [[ -s "${path}/default.gems" ]] ; then
778
+
779
+ ( gems_args="${path}/default.gems" ; gemset_import )
780
+
742
781
  fi
743
782
 
744
- if [[ -s "${gemsets_path}/global.gems" ]] ; then
783
+ if [[ -s "${path}/global.gems" ]] ; then
784
+
745
785
  (
746
- rvm --create "$rvm_ruby_string@global"
747
- "$rvm_path/scripts/gemsets" import "${gemsets_path}/global.gems"
786
+ rvm_create_flag=1
787
+ rvm_ruby_gem_home="${rvm_ruby_gem_home//@*/}@global"
788
+ gems_args="${path}/global.gems"
789
+ gemset_import
748
790
  )
791
+
749
792
  fi
793
+
750
794
  fi
795
+
751
796
  done
752
797
 
753
798
  "$rvm_path/scripts/log" "info" \
@@ -773,10 +818,15 @@ export rvm_gemset_name="${args[1]:-""}" # For wherever used.
773
818
  rvm_sticky_flag=1
774
819
 
775
820
  if [[ -z "$rvm_ruby_string" ]] ; then
821
+
776
822
  if echo "${GEM_HOME:-""}" | grep -q 'rvm' ; then
823
+
777
824
  rvm_ruby_string="${GEM_HOME##*/}"
825
+
778
826
  rvm_ruby_string="${rvm_ruby_string%%@*}"
827
+
779
828
  fi
829
+
780
830
  fi
781
831
 
782
832
  case "$action" in