rvm 0.1.24 → 0.1.26

Sign up to get free protection for your applications and to get access to all the features.
data/scripts/gemsets CHANGED
@@ -10,7 +10,7 @@ if [[ ! -d "$rvm_ruby_gem_home" ]] && which gem &> /dev/null ; then rvm_ruby_gem
10
10
  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
11
11
 
12
12
  __rvm_gemset_name() {
13
- __rvm_gemset_gemdir | awk -F'%' '{print $2}'
13
+ __rvm_gemset_gemdir | awk -F${rvm_gemset_separator} '{print $2}'
14
14
  }
15
15
 
16
16
  __rvm_gemset_dir() {
@@ -18,9 +18,9 @@ __rvm_gemset_dir() {
18
18
  }
19
19
 
20
20
  __rvm_gemset_create() {
21
- rvm_ruby_gem_prefix=$(echo $rvm_ruby_gem_home | sed 's/%.*$//')
21
+ rvm_ruby_gem_prefix=$(echo $rvm_ruby_gem_home | sed 's/'${rvm_gemset_separator}'.*$//')
22
22
  for gemset in $(echo $gems_args) ; do
23
- gem_home="$rvm_ruby_gem_prefix%${gems_args/ /}"
23
+ gem_home="${rvm_ruby_gem_prefix}${rvm_gemset_separator}${gems_args/ /}"
24
24
  mkdir -p $gem_home
25
25
  ln -nfs "$HOME/.gem/cache" "$gem_home/cache"
26
26
  $rvm_scripts_path/log "info" "Gemset '$gemset' created."
@@ -34,8 +34,8 @@ __rvm_gemset_list() {
34
34
 
35
35
  if [[ ! -z "$rvm_gems_path" ]] ; then
36
36
  if [[ ! -z $rvm_ruby_string ]] ; then
37
- for gemdir in $rvm_gems_path/${rvm_ruby_string}%* ; do
38
- echo "$gemdir" | awk -F'%' '{print $2}'
37
+ for gemdir in $rvm_gems_path/${rvm_ruby_string}${rvm_gemset_separator}* ; do
38
+ echo "$gemdir" | awk -F${rvm_gemset_separator} '{print $2}'
39
39
  done
40
40
  else
41
41
  $rvm_scripts_path/log "error" "\$rvm_ruby_string is not set!"
@@ -48,7 +48,7 @@ __rvm_gemset_list() {
48
48
  __rvm_gemset_delete() {
49
49
  if [[ -z "$rvm_ruby_selected_flag" ]] ; then __rvm_select ; fi
50
50
  if [[ ! -z "$rvm_gemset_name" ]] ; then
51
- gemdir="$rvm_gems_path/$rvm_ruby_string%$rvm_gemset_name"
51
+ gemdir="$rvm_gems_path/$rvm_ruby_string${rvm_gemset_separator}$rvm_gemset_name"
52
52
  if [[ -d "$gemdir" ]] && [[ "$gemdir" != '/' ]] && [[ ! -z "$rvm_force_flag" ]] ; then
53
53
  rm -rf "$gemdir"
54
54
  elif [[ -d "$gemdir" ]] ; then
@@ -74,7 +74,7 @@ __rvm_gemset_empty() {
74
74
  if [[ -d "$gemdir" ]] && [[ "$gemdir" != '/' ]] && [[ ! -z "$rvm_force_flag" ]] ; then
75
75
  cd $gemdir && rm -rf ./bin/* ./doc/* ./gems/* ./specifications/*
76
76
  elif [[ -d "$gemdir" ]] ; then
77
- $rvm_scripts_path/log "warn" "Are you SURE you wish to remove the installed gemset for gemset '%$rvm_gemset_name' ($gemdir)?"
77
+ $rvm_scripts_path/log "warn" "Are you SURE you wish to remove the installed gemset for gemset '${rvm_gemset_separator}$rvm_gemset_name' ($gemdir)?"
78
78
  echo -n "(anything other than 'yes' will cancel) > "
79
79
  read response
80
80
  if [[ "yes" = "$response" ]] ; then
@@ -119,7 +119,7 @@ __rvm_gemset_export() {
119
119
 
120
120
  if [[ ! -z "$rvm_ruby_gem_home" ]] ; then
121
121
  export GEM_HOME="$rvm_ruby_gem_home"
122
- export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_gems_path/$rvm_ruby_string%global/bin"
122
+ export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_gems_path/$rvm_ruby_string${rvm_gemset_separator}global/bin"
123
123
  export BUNDLE_PATH="$rvm_ruby_gem_home"
124
124
  fi
125
125
 
@@ -152,7 +152,7 @@ __rvm_gemset_import() {
152
152
 
153
153
  if [[ ! -z "$rvm_ruby_gem_home" ]] ; then
154
154
  export GEM_HOME="$rvm_ruby_gem_home"
155
- export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_gems_path/$rvm_ruby_string%global/bin"
155
+ export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_gems_path/$rvm_ruby_string${rvm_gemset_separator}global/bin"
156
156
  export BUNDLE_PATH="$rvm_ruby_gem_home"
157
157
  fi
158
158
 
@@ -274,9 +274,9 @@ __rvm_gem_install() {
274
274
  if [[ "rvm_make_flags_flag" -eq 1 ]] ; then __rvm_make_flags ; fi
275
275
 
276
276
  if [[ ! -z "$rvm_ruby_gem_home" ]] && [[ "$rvm_ruby_gem_home" != "$rvm_gems_path" ]] ; then
277
- command="GEM_HOME='$rvm_ruby_gem_home' GEM_PATH='$rvm_ruby_gem_home/bin:$rvm_gems_path/$rvm_ruby_string%global/bin' BUNDLE_PATH='$rvm_ruby_gem_home' $gem_prefix gem install $gems_args $rvm_gem_options $gem_postfix $vars"
277
+ 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"
278
278
  else
279
- command="$gem_prefix gem install $gems_args $rvm_gem_options -q $gem $gem_postfix $vars"
279
+ command="$gem_prefix gem install --ignore-dependencies $gems_args $rvm_gem_options -q $gem $gem_postfix $vars"
280
280
  fi
281
281
  __rvm_run "gem.install" "$command" "$gem_name $gem_version is not installed, installing..."
282
282
  result=$?
data/scripts/initialize CHANGED
@@ -23,6 +23,7 @@ rvm_hooks_path="${rvm_hooks_path:-"$rvm_path/hooks"}"
23
23
  rvm_tmp_path="${rvm_tmp_path:-"$rvm_path/tmp"}"
24
24
  rvm_usr_path="${rvm_usr_path:-"$rvm_path/usr"}"
25
25
  rvm_symlink_path="${rvm_symlink_path:-$rvm_prefix/bin}"
26
+ rvm_gemset_separator="${rvm_gemset_separator:-"@"}"
26
27
 
27
- export rvm_path rvm_rubies_path rvm_scripts_path rvm_archives_path rvm_src_path rvm_log_path rvm_bin_path rvm_gems_path rvm_config_path rvm_tmp_path rvm_hooks_path rvm_gems_cache_path
28
+ export rvm_path rvm_rubies_path rvm_scripts_path rvm_archives_path rvm_src_path rvm_log_path rvm_bin_path rvm_gems_path rvm_config_path rvm_tmp_path rvm_hooks_path rvm_gems_cache_path rvm_gemset_separator
28
29
 
data/scripts/install CHANGED
@@ -13,9 +13,9 @@ source scripts/utility
13
13
  usage() {
14
14
  echo -e "
15
15
  Usage:
16
- ${0} <options>
16
+ ${0} [options]
17
17
 
18
- Options:
18
+ options:
19
19
  --auto : Automatically update shell profile files.
20
20
  --prefix : Installation prefix directory.
21
21
  --help : Display help/usage (this) message
@@ -23,6 +23,15 @@ usage() {
23
23
  "
24
24
  }
25
25
 
26
+ spinner_counter=0
27
+ spinner() {
28
+ array=('/' '-' '\\' '|' '/' '-' '\\' '|')
29
+ index=$((($spinner_counter % 8)))
30
+ echo -e -n "\r${array[$index]}"
31
+ let "spinner_counter=spinner_counter+1"
32
+ which perl > /dev/null 2>&1 && perl -e 'sleep 0.5'
33
+ }
34
+
26
35
  if echo "$*" | grep -q 'trace' ; then echo "$*" ; env | grep '^rvm_' ; set -x ; fi
27
36
 
28
37
  while [[ $# -gt 0 ]] ; do
@@ -47,18 +56,25 @@ fi
47
56
  if [[ -z "$rvm_path" ]] ; then rvm_path="${rvm_prefix}rvm" ; fi
48
57
 
49
58
  source scripts/initialize
59
+ if grep -q 'scripts/rvm' $HOME/.bash* || grep -q 'scripts/rvm' $HOME/.zsh*; then
60
+ if [[ -d "$rvm_path" ]] && [[ -s "${rvm_path}/scripts/rvm" ]] ; then
61
+ export upgrade_flag=1
62
+ else
63
+ export upgrade_flag=0
64
+ fi
65
+ else
66
+ export upgrade_flag=0
67
+ fi
68
+
50
69
  __rvm_initialize
51
70
 
52
71
  #
53
- # Setup
72
+ # Setup & Configuration
54
73
  #
55
74
  item="$(tput setaf 2)* $(tput sgr0)"
56
75
  question="\n$(tput setaf 2)<?>$(tput sgr0)"
57
76
  cwd=$(pwd)
58
77
  source_path="${source_path:-$cwd}"
59
-
60
- # State what is required to use rvm
61
- echo -e "\nInstalling rvm to $rvm_path/ ..."
62
78
  rvm_archives_path="${rvm_archives_path:-"$rvm_path/archives"}"
63
79
  rvm_src_path="${rvm_src_path:-"$rvm_path/src"}"
64
80
  rvm_log_path="${rvm_log_path:-"$rvm_path/log"}"
@@ -71,9 +87,25 @@ rvm_hooks_path="${rvm_hooks_path:-"$rvm_path/hooks"}"
71
87
  rvm_tmp_path="${rvm_tmp_path:-"$rvm_path/tmp"}"
72
88
  rvm_symlink_path="${rvm_symlink_path:-$rvm_prefix/bin}"
73
89
 
90
+ export rvm_gemset_separator="@" # TODO: Remove this after a while.
91
+
92
+ echo -e "\n$(tput setaf 2)RVM$(tput sgr0) - shell scripts which allow management of multiple ruby interpreters and environments."
93
+ echo -e "\n $(tput setaf 2)RTFM: $(tput sgr0) http://rvm.beginrescueend.com/"
94
+ echo -e "\n $(tput setaf 2)HELP: $(tput sgr0) http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)"
95
+
96
+ echo -e "\n********************************************************************************"
97
+ if [[ "$upgrade_flag" -eq 1 ]] ;then
98
+ echo -e -n " Upgrading the RVM installation in $rvm_path/"
99
+ else
100
+ echo -e -n " Installing rvm to $rvm_path/"
101
+ fi
102
+
103
+ spinner
104
+
74
105
  mkdir -p $rvm_archives_path $rvm_src_path $rvm_log_path $rvm_bin_path $rvm_gems_path $rvm_rubies_path $rvm_config_path $rvm_hooks_path $rvm_tmp_path $rvm_symlink_path $HOME/.gem/cache
75
106
 
76
107
  for file in README LICENCE ; do
108
+ spinner
77
109
  cp -f "$source_path/$file" "$rvm_path/"
78
110
  done
79
111
 
@@ -81,19 +113,22 @@ done
81
113
  # Scripts
82
114
  #
83
115
  for dir_name in config scripts examples lib hooks ; do
116
+ spinner
84
117
  mkdir -p "$rvm_path/$dir_name"
85
118
  if [[ -d "$source_path/$dir_name" ]] ; then
86
119
  cp -Rf "$source_path/$dir_name" "$rvm_path"
87
120
  fi
88
121
  done ; unset dir_name
89
122
 
123
+ spinner
90
124
  if [[ ! -s "$rvm_config_path/user" ]] ; then
91
125
  mkdir -p "$rvm_config_path/"
92
126
  echo '# Users settings file, overrides db file settings and persists across installs.' >> $rvm_config_path/user
93
127
  fi
94
128
 
95
- scripts="monitor match log install color db fetch log set package"
96
- for script_name in $(echo $scripts) ; do
129
+ scripts=("monitor" "match" "log" "install" "color" "db" "fetch" "log" "set" "package")
130
+ for script_name in $scripts ; do
131
+ spinner
97
132
  chmod +x $rvm_scripts_path/$script_name
98
133
  done
99
134
 
@@ -102,14 +137,17 @@ done
102
137
  #
103
138
  # Cleanse and purge...
104
139
  for file in rvm-prompt rvm rvmsudo ; do
140
+ spinner && perl -e 'sleep 0.2'
105
141
  rm -f "$rvm_bin_path/$file"
106
142
  cp -f "$source_path/binscripts/$file" $rvm_bin_path/
107
143
  done
144
+ spinner
108
145
  chmod +x $rvm_bin_path/*
109
146
 
110
147
  #
111
148
  # RC Files
112
149
  #
150
+ spinner
113
151
  if [[ ! -z "$rvm_auto_flag" ]] ; then
114
152
  echo -e "Checking rc files... ($rvm_rc_files)"
115
153
  if [[ "$rvm_loaded_flag" != "1" ]] ; then
@@ -134,11 +172,13 @@ fi
134
172
  #
135
173
  rvm_rubies_path="${rvm_rubies_path:-"$rvm_path/rubies"}"
136
174
  mkdir -p "$rvm_rubies_path/"
175
+ spinner
137
176
  for ruby in $rvm_path/ruby-* $rvm_path/jruby-* $rvm_path/mput-* $rvm_path/rbx-* $rvm_path/maglev-* $rvm_path/ree-* ; do
138
177
  if [[ -d "$ruby" ]] ; then
139
178
  mv "$ruby" "$rvm_rubies_path/"
140
179
  new_path="$rvm_rubies_path/$(basename $ruby)"
141
180
  for file in gem rake ; do
181
+ spinner
142
182
  if [[ -s "$new_path/bin/$file" ]] ; then
143
183
  sed -i.orig -e '1,1s=.*=#!'"$new_path/bin/ruby=" "$new_path/bin/$file"
144
184
  rm -f "$new_path/bin/$file.orig"
@@ -148,7 +188,46 @@ for ruby in $rvm_path/ruby-* $rvm_path/jruby-* $rvm_path/mput-* $rvm_path/rbx-*
148
188
  fi
149
189
  done
150
190
  #
151
- # End of migration.
191
+ # End of rubies migration.
192
+ #
193
+
194
+ #
195
+ # Migrate old gemset directories to new gemset pattern.
196
+ #
197
+ spinner
198
+ echo -e -n "\r*" # Stop spinner.
199
+
200
+ for gemset in $rvm_path/gems/*\%* ; do
201
+ new_path=${gemset/\%/${rvm_gemset_separator}}
202
+ if [[ -d "$gemset" ]] && [[ ! -d "$new_path" ]] ; then
203
+ echo -e " Renaming $(basename $gemset) to $(basename $new_path) for new gemset separator."
204
+ mv $gemset $new_path
205
+ fi
206
+ done
207
+
208
+ for gemset in $rvm_path/gems/*\+* ; do
209
+ new_path=${gemset/\+/${rvm_gemset_separator}}
210
+ if [[ -d "$gemset" ]] && [[ ! -d "$new_path" ]] ; then
211
+ echo -e " Renaming $(basename $gemset) to $(basename $new_path) for new gemset separator."
212
+ mv $gemset $new_path
213
+ fi
214
+ done
215
+ for gemset in $rvm_path/gems/*\@ ; do
216
+ new_path=$(echo $gemset | sed -e 's#\@$##')
217
+ if [[ -d "$gemset" ]] && [[ ! -d "$new_path" ]] ; then
218
+ echo -e " Fixing: $(basename $gemset) to $(basename $new_path) for new gemset separator."
219
+ mv $gemset $new_path
220
+ fi
221
+ done
222
+
223
+ # Upgrade any default file.
224
+ if [[ -s $rvm_config_path/default ]] && grep -q '\%' $rvm_config_path/default ; then
225
+ sed -e "s#\%#${rvm_gemset_separator}#g" $rvm_config_path/default > $rvm_config_path/default.new
226
+ mv $rvm_config_path/default.new $rvm_config_path/default
227
+ fi
228
+
229
+ #
230
+ # End of gemset migration.
152
231
  #
153
232
 
154
233
  if [[ "root" = "$(whoami)" ]] ; then
@@ -160,11 +239,11 @@ if [[ "root" = "$(whoami)" ]] ; then
160
239
  chmod +x $rvm_symlink_path/rvmsudo
161
240
  fi
162
241
 
163
- echo -e "\n$(tput setaf 2)rvm$(tput sgr0) - shell scripts that allows a user to manage multiple ruby versions in their own account."
164
- ./scripts/notes
242
+ if [[ "$upgrade_flag" -eq 0 ]] ; then
243
+ echo -e "\n********************************************************************************"
244
+ ./scripts/notes
245
+ fi
165
246
 
166
- echo -e "$(tput setaf 2)RTFM: $(tput sgr0) http://rvm.beginrescueend.com/"
167
- echo -e "\n$(tput setaf 2)HELP: $(tput sgr0) http://webchat.freenode.net/?channels=rvm "
168
247
  echo -e "\n********************************************************************************"
169
248
  name="$(awk -F= '/^[[:space:]]*name/{print $2}' ~/.gitconfig 2>/dev/null)"
170
249
  echo -e "\n${name:-"$(whoami)"},\n"
@@ -177,20 +256,28 @@ echo -e "\n w$(tput setaf 2)⦿‿⦿$(tput sgr0)t!"
177
256
  echo -e "\n ~ Wayne"
178
257
  echo -e "\n********************************************************************************"
179
258
 
180
- if [[ "root" != "$(whoami)" ]] ; then
181
- echo -e "\n$(tput setaf 1)You must now finish the install manually:$(tput sgr0)"
182
- echo -e "\n1) Place the folowing line at the end of your shell's loading files(.bashrc and then .bash_profile for bash and .zshrc for zsh), after all path/variable settings:"
183
- echo -e "\n if [[ -s $rvm_path/scripts/rvm ]] ; then source $rvm_path/scripts/rvm ; fi"
184
- echo -e "\n2) Ensure that there is no 'return' from inside the .bashrc file. (otherwise rvm will be prevented from working properly)."
185
- echo -e "\n This means that if you see '[ -z "$PS1" ] && return' then you must remove it and split your .bashrc"
186
- echo -e "\n Put everything *except the return code line(s)* into your .bash_profile, and everything above that code in your .bashrc."
187
- echo -e "\n Be *sure* to REMOVE the '&& return' statement line."
188
- echo -e "\n If you wish to DRY up your config you can 'source ~/.bashrc' at the top of your .bash_profile."
189
- echo -e "\n4) Then $(tput setaf 1)CLOSE THIS SHELL$(tput sgr0) and open a new one in order to use rvm.\n"
190
- fi
191
-
192
- if [[ -s $HOME/.bashrc ]] && grep '&& return' $HOME/.bashrc ; then
193
- echo -e "\n\nWARNING: you have a 'return' statement in your .bashrc, likely this will cause untold havoc. Please remove it and refactor your profiles to be correct. If you have questions about this please visit #rvm on irc.freenode.net.\n\n"
259
+ if [[ "$upgrade_flag" -eq 1 ]] ; then
260
+ echo -e "\n$(tput setaf 6)**** NOTICE *************************************************************************************"
261
+ echo -e "* Gemset separator has changed, it is now @ and will remain unless any rubies error using it. *"
262
+ echo -e "* If you encounter any issues with a ruby your best bet is to 'rvm remove X ; rvm install X' *"
263
+ echo -e "*************************************************************************************************$(tput sgr0)\n"
264
+ echo -e "Upgrade of RVM in $rvm_path/ is complete.\n"
265
+ else
266
+ if [[ "root" != "$(whoami)" ]] ; then
267
+ echo -e "\n$(tput setaf 1)You must now finish the install manually:$(tput sgr0)"
268
+ echo -e "\n1) Place the folowing line at the end of your shell's loading files(.bashrc and then .bash_profile for bash and .zshrc for zsh), after all path/variable settings:"
269
+ echo -e "\n if [[ -s $rvm_path/scripts/rvm ]] ; then source $rvm_path/scripts/rvm ; fi"
270
+ echo -e "\n2) Ensure that there is no 'return' from inside the .bashrc file. (otherwise rvm will be prevented from working properly)."
271
+ echo -e "\n This means that if you see '[ -z "$PS1" ] && return' then you must remove it and split your .bashrc"
272
+ echo -e "\n Put everything *except the return code line(s)* into your .bash_profile, and everything above that code in your .bashrc."
273
+ echo -e "\n Be *sure* to REMOVE the '&& return' statement line."
274
+ echo -e "\n If you wish to DRY up your config you can 'source ~/.bashrc' at the top of your .bash_profile."
275
+ echo -e "\n4) Then $(tput setaf 1)CLOSE THIS SHELL$(tput sgr0) and open a new one in order to use rvm.\n"
276
+ fi
277
+ if [[ -s $HOME/.bashrc ]] && grep '&& return' $HOME/.bashrc ; then
278
+ echo -e "\n\nWARNING: you have a 'return' statement in your .bashrc, likely this will cause untold havoc. Please remove it and refactor your profiles to be correct. If you have questions about this please visit #rvm on irc.freenode.net.\n"
279
+ fi
280
+ echo -e "Installation of RVM to $rvm_path/ is complete.\n\n"
194
281
  fi
195
282
 
196
283
  exit 0
data/scripts/manage CHANGED
@@ -152,8 +152,8 @@ __rvm_install_ruby() {
152
152
  mkdir -p "$rvm_ruby_home/bin"
153
153
  fi
154
154
 
155
- binaries="erb gem irb rake rdoc ri ruby testrb" # Trick to work in more shells :)
156
- for binary_name in $(echo $binaries); do
155
+ binaries=(erb gem irb rake rdoc ri ruby testrb)
156
+ for binary_name in ${binaries[@]}; do
157
157
  # if [[ $binary_name != "gem" ]] ; then prefix="-S" ; fi
158
158
  ruby_wrapper=$(cat <<RubyWrapper
159
159
  #!/usr/bin/env bash
@@ -226,7 +226,7 @@ RubyWrapper
226
226
 
227
227
  __rvm_rubygems_setup
228
228
 
229
- for rvm_gem_name in rake ; do
229
+ for rvm_gem_name in rdoc rake ; do
230
230
  __rvm_run "gems" "$rvm_ruby_home/bin/gem install $rvm_gem_name $rvm_gem_options" "Installing $rvm_gem_name"
231
231
  done
232
232
  __rvm_inject_ruby_shebang "$rvm_ruby_gem_home/bin/rake"
@@ -486,7 +486,6 @@ RubyWrapper
486
486
  $rvm_scripts_path/log "info" "Generating smalltalk FFI."
487
487
  $rvm_bin_path/rvm 1.8.7 rake stwrappers >/dev/null 2>&1
488
488
 
489
-
490
489
  # TODO: Figure out if anything needs to be done with rubygems.
491
490
  #__rvm_rubygems_setup
492
491
  __rvm_irbrc
@@ -554,7 +553,7 @@ RubyWrapper
554
553
  cp -r $rvm_ruby_src_path/Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby/* $rvm_ruby_home/lib/ruby
555
554
  cp -r $rvm_ruby_src_path/Merlin/Main/Languages/Ruby/Libs/* $rvm_ruby_home/lib/IronRuby
556
555
 
557
- binaries="gem irb rake rdoc ri ruby"
556
+ binaries="gem irb rdoc rake ri ruby"
558
557
  for binary_name in $(echo $binaries); do
559
558
  binary_path=""
560
559
  if [[ "ruby" != "$binary_name" ]] ; then
@@ -797,7 +796,7 @@ __rvm_uninstall_ruby() {
797
796
  rm -f $rvm_bin_path/$rvm_ruby_string
798
797
  fi
799
798
  done ; unset dir
800
- rm -rf $rvm_gems_path/$rvm_ruby_interpreter/$rvm_ruby_version*/
799
+ __rvm_remove_gemsets
801
800
  else
802
801
  $rvm_scripts_path/log "fail" "Cannot uninstall unknown package '$rvm_ruby_string'"
803
802
  fi ; unset rvm_uninstall_flag
@@ -818,11 +817,20 @@ __rvm_remove_ruby() {
818
817
  rm -f $rvm_bin_path/$rvm_ruby_string
819
818
  fi
820
819
  done ; unset dir
820
+ __rvm_remove_gemsets
821
821
  else
822
822
  $rvm_scripts_path/log "fail" "Cannot uninstall unknown package '$rvm_ruby_string'"
823
823
  fi ; unset rvm_remove_flag
824
824
  }
825
825
 
826
+ __rvm_remove_gemsets() {
827
+ if [[ ! -z "$rvm_gems_flag" ]] ; then
828
+ if [[ -d "$rvm_gems_path/${rvm_ruby_string}${rvm_gemset_separator}${rvm_gemset_name}" ]] ; then
829
+ rm -rf $rvm_gems_path/${rvm_ruby_string}*
830
+ fi
831
+ fi
832
+ }
833
+
826
834
  __rvm_post_install() {
827
835
  binaries="${binaries:-"gem irb erb ri rdoc testrb rake"}"
828
836
  for binary in $(echo $binaries) ; do
@@ -840,25 +848,26 @@ __rvm_post_install() {
840
848
 
841
849
  $rvm_scripts_path/log "info" "Installing gems for $rvm_ruby_string."
842
850
 
843
- for rvm_gem_name in rake ; do
851
+ for rvm_gem_name in rdoc rake ; do
844
852
  home="$GEM_HOME" ; path="$GEM_PATH" # Save
845
- export GEM_HOME="$rvm_ruby_global_gems_path"
846
- export GEM_PATH="$rvm_ruby_global_gems_path"
847
- export BUNDLE_PATH="$rvm_ruby_global_gems_path"
848
- __rvm_run "gems.install" "$rvm_ruby_home/bin/gem install $rvm_gem_name $rvm_gem_options" "Installing $rvm_gem_name"
849
- export GEM_HOME="$home" ; export GEM_PATH="$path" ; export BUNDLE_PATH="$home" ; unset home path
853
+ for dir in $rvm_ruby_global_gems_path $rvm_ruby_gem_home ; do
854
+ GEM_HOME="$dir" ; GEM_PATH="$dir" ; BUNDLE_PATH="$dir"
855
+ export GEM_HOME GEM_PATH BUNDLE_PATH
856
+ __rvm_run "gems.install" "$rvm_ruby_home/bin/gem install --no-rdoc --no-ri $rvm_gem_name $rvm_gem_options" "Installing $rvm_gem_name"
857
+
858
+ if [[ -x $rvm_ruby_gem_home/bin/$rvm_gem_name ]] ; then
859
+ if [[ "$rvm_ruby_gem_home" != "$rvm_ruby_home" ]] && [[ ! -x $rvm_ruby_home/bin/$rvm_gem_name ]] ; then
860
+ ln -nfs $rvm_ruby_gem_home/bin/$rvm_gem_name $rvm_ruby_home/bin/$rvm_gem_name
861
+ fi
862
+ __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/$rvm_gem_name"
863
+ __rvm_inject_gem_env "$rvm_ruby_home/bin/$rvm_gem_name"
864
+ fi ; unset rvm_gem_name
865
+ done ; unset home path dir
866
+ GEM_HOME="$home" ; GEM_PATH="$path" ; BUNDLE_PATH="$home"
867
+ export GEM_HOME GEM_PATH BUNDLE_PATH
850
868
  done ; unset rvm_gem_name
851
-
852
869
  $rvm_scripts_path/log "info" "Installation of gems for $rvm_ruby_string is complete."
853
870
 
854
- binary=rake
855
- if [[ -x $rvm_ruby_gem_home/bin/$binary ]] ; then
856
- if [[ "$rvm_ruby_gem_home" != "$rvm_ruby_home" ]] ; then
857
- cp $rvm_ruby_gem_home/bin/$binary $rvm_ruby_home/bin/$binary
858
- fi
859
- __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/$binary"
860
- __rvm_inject_gem_env "$rvm_ruby_home/bin/$binary"
861
- fi ; unset binary
862
871
  __rvm_irbrc
863
872
  }
864
873
 
@@ -877,18 +886,22 @@ __rvm_rubygems_setup() {
877
886
  # 1.9.X has it's own built-in gem command
878
887
  __rvm_inject_ruby_shebang "$rvm_ruby_src_path/bin/gem"
879
888
  __rvm_inject_gem_env "$rvm_ruby_home/bin/gem"
889
+
880
890
  cp $rvm_ruby_src_path/bin/gem $rvm_ruby_home/bin/gem
891
+
881
892
  home="$GEM_HOME" ; path="$GEM_PATH" # Save
882
- export GEM_HOME="$rvm_ruby_global_gems_path"
883
- export GEM_PATH="$rvm_ruby_global_gems_path"
884
- export BUNDLE_PATH="$rvm_ruby_global_gems_path"
885
- __rvm_run "rubygems.update" "$rvm_ruby_home/bin/gem update --system" "Updating rubygems for $rvm_ruby_string"
886
- export GEM_HOME="$home" ; export GEM_PATH="$path" ; export BUNDLE_PATH="$home" unset home path
893
+ for dir in $rvm_ruby_global_gems_path $rvm_ruby_gem_home ; do
894
+ export GEM_HOME="$dir" ; export GEM_PATH="$dir" ; export BUNDLE_PATH="$dir"
895
+ __rvm_run "rubygems.update" "$rvm_ruby_home/bin/gem update --system" "Updating rubygems for $dir"
896
+ done ; unset home path dir
897
+ GEM_HOME="$home" ; GEM_PATH="$path" ; BUNDLE_PATH="$home"
898
+ export GEM_HOME GEM_PATH BUNDLE_PATH
887
899
 
888
900
  __rvm_inject_ruby_shebang "$rvm_ruby_home/bin/gem"
889
901
  __rvm_inject_gem_env "$rvm_ruby_home/bin/gem"
890
902
  ruby_lib_gem_path="$rvm_ruby_home/lib/ruby/gems/1.$rvm_major_version"
891
903
  elif [[ ! -z "$(echo $rvm_ruby_interpreter | awk '/^rbx|jruby/')" ]] ; then
904
+ # Hands off rubygems for rbx & jruby
892
905
  if [[ ! -z "$rvm_debug_flag" ]] ; then $rvm_scripts_path/log "debug" "Skipping rubygems update for $rvm_ruby_version" ; fi
893
906
  ruby_lib_gem_path="$rvm_ruby_home/lib/ruby/gems/jruby"
894
907
  else
@@ -898,7 +911,8 @@ __rvm_rubygems_setup() {
898
911
  rvm_gem_package_name="rubygems-$rvm_rubygems_version"
899
912
  rvm_gem_url="$rvm_rubygems_url/$rvm_gem_package_name.tgz"
900
913
 
901
- # Sanity check...
914
+ # Sanity check... If setup.rb is missing from the rubygems source path,
915
+ # something went wrong. Cleanup, aisle 3!
902
916
  if [[ ! -f "$rvm_src_path/$rvm_gem_package_name/setup.rb" ]]; then
903
917
  rm -rf "$rvm_src_path/$rvm_gem_package_name"
904
918
  fi
@@ -934,12 +948,17 @@ __rvm_rubygems_setup() {
934
948
 
935
949
  # Add ruby's gem path to ruby's lib direcotry.
936
950
  mkdir -p $(dirname $ruby_lib_gem_path)
937
- if [[ -d "$ruby_lib_gem_path" ]] ; then
938
- rm -rf "$ruby_lib_gem_path"
939
- fi
951
+
952
+ if [[ -d "$ruby_lib_gem_path" ]] ; then rm -rf "$ruby_lib_gem_path" ; fi
953
+
940
954
  ln -nfs "$rvm_ruby_gem_home" "$ruby_lib_gem_path"
955
+
941
956
  unset ruby_lib_gem_path
942
957
 
958
+ if [[ -s "$rvm_ruby_src_path/bin/rdoc" ]] ; then
959
+ __rvm_inject_ruby_shebang "$rvm_ruby_src_path/bin/rdoc"
960
+ fi
961
+
943
962
  if [[ -s "$rvm_ruby_src_path/bin/rake" ]] ; then
944
963
  __rvm_inject_ruby_shebang "$rvm_ruby_src_path/bin/rake"
945
964
  fi
@@ -986,8 +1005,8 @@ __rvm_manage_rubies() {
986
1005
 
987
1006
  unset rvm_gemset_name rvm_ruby_selected_flag
988
1007
 
989
- rvm_ruby_gem_home=$(echo $rvm_ruby_gem_home | awk -F'%' '{print $1}')
990
- rvm_ruby_string=$(echo $rvm_ruby_string | awk -F'%' '{print $1}')
1008
+ rvm_ruby_gem_home=$(echo $rvm_ruby_gem_home | awk -F${rvm_gemset_separator} '{print $1}')
1009
+ rvm_ruby_string=$(echo $rvm_ruby_string | awk -F${rvm_gemset_separator} '{print $1}')
991
1010
 
992
1011
  # TODO: Extract the common functionality out of the if below
993
1012
  #if [[ ! -z "$rvm_ruby_string" ]] ; then