-
Notifications
You must be signed in to change notification settings - Fork 1
/
rvm
executable file
·1070 lines (896 loc) · 42 KB
/
rvm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/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.26"
rvm_meta_updated="2009.08.31"
}
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)
reload - Reload rvm source itself (useful after changing rvm source)
rubydo - Used with -f to run a ruby file against specified or all rubies
debug - Emit environment & configuration information for *current* ruby
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)
-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 - Specifies the path for binaries to be placed
-S|--source - Specifies the src directory to use
-A|--archive - Specifies the archive directory to use (tabralls / zips)
-G|--gems - Specifies the root gem path to use
-C|--configure - Specifies any custom command line configure options
-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.
--rm-gem-set - Remove a named gem set
--debug - 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 <d> $* \033[0m" ;;
info) shift ; echo -e "\n\033[0;32m <i> $* \033[0m" ;;
warn) shift ; echo -e "\n\033[0;33m <w> $* \033[0m" ;;
fail) shift ; echo -e "\n\033[0;31m <e> $* \033[0m" ; 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' ':'`
PATH="${PATH%:}"
export PATH
}
function __rvm_remove-from-path {
PATH=`echo $PATH | tr -s ':' '\n' | grep -v "\.rvm" | tr -s '\n' ':'`
PATH="${PATH%:}"
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 [ ! -f $rvm_install_path/default ] ; then
for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME PATH ; do
eval "export $variable"
eval value=\$${variable}
echo "${variable}='$value' ; export ${variable}" >> $rvm_install_path/default
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_curl=`which curl`
if [ $? -ne 0 ] ; then
__rvm_log "fail" "rvm expects that curl is available, which curl shows no curl :("
else
rvm_curl="$rvm_curl -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"}"
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_jruby_repo_url="${rvm_jruby_repo_url:-"git://kenai.com/jruby~main"}"
if [ ! -z "$rvm_ruby_configure" ] ; then
rvm_ruby_configure="$(echo $rvm_ruby_configure | tr ',-' ' -')"
fi
__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_install_path/bin $rvm_archives_path
}
function __rvm_curl {
pushd $rvm_archives_path > /dev/null
eval $rvm_curl "$1"
popd > /dev/null
}
function __rvm_install-source {
if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi
__rvm_log "info" "Installing Ruby from source to: $rvm_install_path/$rvm_ruby_package_name"
mkdir -p $rvm_log_path/$rvm_ruby_package_name
pushd $rvm_source_path > /dev/null
if [ -z "$rvm_ruby_tag" -a -z "$rvm_ruby_rev" ] ; then
if [ ! -d $rvm_source_path/$rvm_ruby_package_name ] ; 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_curl $rvm_url
__rvm_log "info" "\tExtracting $rvm_ruby_package_name ..."
mkdir -p $rvm_source_path/$rvm_ruby_package_name
nice -n $rvm_niceness tar xzf $rvm_archives_path/$rvm_ruby_package_name.tar.gz -C $rvm_source_path
fi
cd $rvm_source_path/$rvm_ruby_package_name
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
__rvm_log "info" "\tRetrieving Ruby from $rvm_url"
mkdir -p $rvm_source_path/$rvm_ruby_package_name
# TODO: Instead of always forcing, check if it's already svn for correct url and simply check out required revision
svn checkout -q $rvm_rev --force $rvm_url $rvm_source_path/$rvm_ruby_package_name
cd $rvm_source_path/$rvm_ruby_package_name
autoconf
fi
if [ -s ./configure ] ; then
__rvm_log "info" "\tConfiguring $rvm_ruby_package_name using ${rvm_ruby_configure:-"--enable-shared"}, this may take a while depending on your cpu(s)..."
nice -n $rvm_niceness ./configure --prefix=$rvm_install_path/$rvm_ruby_package_name ${rvm_ruby_configure:-"--enable-shared"} > $rvm_log_path/$rvm_ruby_package_name/configure.log 2> $rvm_log_path/$rvm_ruby_package_name/configure.error.log
if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_package_file/*.error.log" ; return 1 ; fi
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
nice -n $rvm_niceness make > $rvm_log_path/$rvm_ruby_package_name/make.log 2> $rvm_log_path/$rvm_ruby_package_name/make.error.log
else
nice -n $rvm_niceness $rvm_ruby_make > $rvm_log_path/$rvm_ruby_package_name/install.log 2> $rvm_log_path/$rvm_ruby_package_name/install.error.log
fi
if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_package_file/*.error.log" ; return 1 ; fi
if [ -z "$rvm_ruby_make" ] ; then
__rvm_log "info" "\tInstalling $rvm_ruby_package_name"
nice -n $rvm_niceness make install > $rvm_log_path/$rvm_ruby_package_name/install.log 2> $rvm_log_path/$rvm_ruby_package_name/install.error.log
else
nice -n $rvm_niceness $rvm_ruby_make_install > $rvm_log_path/$rvm_ruby_package_name/install.log 2> $rvm_log_path/$rvm_ruby_package_name/install.error.log
fi
if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_package_file/*.error.log" ; return 1 ; fi
chmod +x $rvm_install_path/$rvm_ruby_package_name/bin/*
ln -fs $rvm_install_path/$rvm_ruby_package_name/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_curl $rvm_gem_url
mkdir -p $rvm_source_path/$rvm_gem_package_name
nice -n $rvm_niceness 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
nice -n $rvm_niceness $rvm_install_path/$rvm_ruby_package_name/bin/ruby $rvm_source_path/$rvm_gem_package_name/setup.rb > $rvm_log_path/$rvm_ruby_package_name/rubygems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/rubygems.install.error.log
popd > /dev/null
__rvm_log "info" "Installation of $rvm_ruby_package_name complete."
for rvm_gem_name in rake ; do
__rvm_log "info" "Installing $rvm_gem_name"
nice -n $rvm_niceness $rvm_install_path/$rvm_ruby_package_name/bin/gem install $rvm_gem_name --no-rdoc --no-ri -q >> $rvm_log_path/$rvm_ruby_package_name/gems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/gems.error.log
done
}
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"
rvm_ruby_make_install="rake install"
rvm_ruby_rev="head"
DESTDIR="$rvm_install_path/$rvm_ruby_package_name" ; export DESTDIR
if [ -z "$rvm_ruby_rev" ] ; then
# TODO: Check if tag v is valid
rvm_ruby_url=$rvm_ruby_repo_url/tags/$rvm_ruby_tag
rvm_ruby_rev=""
else
if [ "$rvm_ruby_rev" = "head" -o "$rvm_ruby_rev" = "trunk" ] ; then
rvm_ruby_url=$rvm_ruby_repo_url/trunk
rvm_ruby_rev=""
else
rvm_ruby_url=$rvm_ruby_repo_url/trunk
rvm_ruby_rev="-r $rvm_ruby_rev"
fi
fi
__rvm_log "info" "\tRetrieving MacRuby from $rvm_url"
#mkdir -p $rvm_source_path/$rvm_ruby_package_name
# TODO: Instead of always forcing, check if it's already svn for correct url and simply check out required revision
#svn checkout -q $rvm_rev --force $rvm_url $rvm_source_path/$rvm_ruby_package_name
cd $rvm_source_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_install_path/$rvm_ruby_package_name"
pushd $rvm_source_path > /dev/null
if [ -d $rvm_source_path/$rvm_ruby_package_name ] ; then
cd $rvm_source_path/$rvm_ruby_package_name
else
__rvm_log "info" "\tDownloading $rvm_ruby_package_name, this may take a while depending on your connection..."
__rvm_curl $rvm_url
__rvm_log "info" "\tExtracting $rvm_ruby_package_name..."
mkdir -p $rvm_source_path/$rvm_ruby_package_name
nice -n $rvm_niceness tar xzf $rvm_archives_path/$rvm_ruby_package_name.tar.gz -C $rvm_source_path
fi
if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_package_file/*.error.log" ; return 1 ; fi
__rvm_log "info" "\tInstalling $rvm_ruby_package_name, this may take a while, depending on your cpu(s)..."
mkdir -p $rvm_log_path/$rvm_ruby_package_name
cd $rvm_source_path/$rvm_ruby_package_name
nice -n $rvm_niceness ./installer -a $rvm_install_path/ruby-enterprise-$rvm_ruby_version-$rvm_ruby_patch_level --dont-install-useful-gems --no-tcmalloc > $rvm_log_path/$rvm_ruby_package_name/install.log 2> $rvm_log_path/$rvm_ruby_package_name/install.error.log
if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_package_file/*.error.log" ; return 1 ; fi
chmod +x $rvm_install_path/$rvm_ruby_package_name/bin/*
ln -fs $rvm_install_path/$rvm_ruby_package_name/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_curl $rvm_gem_url
mkdir -p $rvm_source_path/$rvm_gem_package_name
nice -n $rvm_niceness tar zxf $rvm_archives_path/$rvm_gem_package_name.tgz -C $rvm_source_path
fi
if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_package_file/*.error.log" ; return 1 ; 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_log_path/$rvm_ruby_package_name/rubygems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/rubygems.install.error.log
nice -n $rvm_niceness $rvm_install_path/$rvm_ruby_package_name/bin/ruby $rvm_source_path/$rvm_gem_package_name/setup.rb > $rvm_log_path/$rvm_ruby_package_name/rubygems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/rubygems.install.error.log
__rvm_log "info" "Installation of $rvm_ruby_package_name complete."
popd > /dev/null
for rvm_gem_name in rake ; do
__rvm_log "info" "Installing $rvm_gem_name"
nice -n $rvm_niceness $rvm_install_path/$rvm_ruby_package_name/bin/gem install $rvm_gem_name --no-rdoc --no-ri -q >> $rvm_log_path/$rvm_ruby_package_name/gems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/gems.error.log
done
;;
rbx|rubinius)
rvm_ruby_repo_url=$rvm_rubinius_repo_url
rvm_ruby_configure=""
rvm_ruby_make="rake"
rvm_ruby_make_install="rake install"
#rvm_ruby_rev="head"
# TODO: Check if already git repo, then git pull origin master && build
if [ ! -d $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version -o ! -d $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version/.git ] ; then
rm -rf $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version
git clone --depth 1 $rvm_ruby_repo_url $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version
fi
cd $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version && rake build
if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_package_file/*.error.log" ; return 1 ; fi
for binary in ruby irb ; do
ln -fs $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version/bin/rbx $rvm_install_path/$rvm_ruby_interpreter-$rvm_ruby_version/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_install_path/$rvm_ruby_package_name"
mkdir -p $rvm_log_path/$rvm_ruby_package_name
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_source_path/$rvm_ruby_package_name
cd $rvm_source_path/$rvm_ruby_package_name && ant
fi
else
if [ -d $rvm_source_path/$rvm_ruby_package_name ] ; then
cd $rvm_source_path/$rvm_ruby_package_name
else
__rvm_log "info" "\tDownloading $rvm_package_file, this may take a while depending on your connection..."
__rvm_curl $rvm_url
__rvm_log "info" "\tExtracting $rvm_package_file..."
nice -n $rvm_niceness unzip -q $rvm_archives_path/$rvm_package_file.zip -d $rvm_source_path
cd $rvm_source_path/$rvm_ruby_package_name
fi
fi
if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_package_file/*.error.log" ; return 1 ; fi
__rvm_log "info" "\tInstalling $rvm_ruby_package_name..."
mkdir -p $rvm_install_path/$rvm_ruby_package_name/bin/
rsync -ag $rvm_source_path/$rvm_ruby_package_name/ $rvm_install_path/$rvm_ruby_package_name/
if [ $? -gt 0 ] ; then __rvm_log "error" "There was an error, please check $rvm_log_path/$rvm_package_file/*.error.log" ; return 1 ; fi
cd $rvm_source_path/$rvm_ruby_package_name/tool/nailgun && make > $rvm_log_path/$rvm_ruby_package_name/install.nailgun.log 2> $rvm_log_path/$rvm_ruby_package_name/install.error.nailgun.log
popd > /dev/null
chmod +x $rvm_install_path/$rvm_ruby_package_name/bin/*
for binary in jruby jgem jirb ; do
ln -fs $rvm_install_path/$rvm_ruby_package_name/bin/$binary $rvm_install_path/$rvm_ruby_package_name/bin/${binary#j}
done
ln -fs $rvm_install_path/$rvm_ruby_package_name/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"
nice -n $rvm_niceness $rvm_install_path/$rvm_ruby_package_name/bin/jgem install $rvm_gem_name --no-rdoc --no-ri -q >> $rvm_log_path/$rvm_ruby_package_name/gems.install.log 2> $rvm_log_path/$rvm_ruby_package_name/gems.error.log
done
;;
ruby)
__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
}
# __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="head" # For now we are only supporting latest
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:-p369}"
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_irbrc="$rvm_ruby_home/.irbrc"
rvm_ruby_binary="$rvm_ruby_home/bin/ruby"
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 <<Config
require "irb/completion" rescue nil
@prompt = {
:PROMPT_I => "${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
cat ~/.irbrc > $rvm_ruby_home/.irbrc
fi
echo "$rvm_irbrc_file" >> $rvm_ruby_home/.irbrc
fi
PATH=$MY_RUBY_HOME/bin:$GEM_HOME/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_default_path ; export PATH" > $rvm_install_path/current
for variable in 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_symlinks {
mkdir -p ${rvm_install_path}/bin
for release in `/bin/ls $rvm_install_path | grep 'ruby-'` ; do
for binary in ruby 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 {
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"
}
function __rvm_reset {
__rvm_select "system"
PATH="$rvm_default_path" ; export PATH
for variable in RUBY_VERSION GEM_HOME MY_RUBY_HOME ; do unset $variable ; done
rm -f $rvm_install_path/default*
rm -f $rvm_install_path/current
}
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 [ "$rvm_ruby_interpreter" -a "$rvm_ruby_version" ] ; then
rvm_ruby_source_dir="$rvm_source_path/$rvm_ruby_interpreter-$rvm_ruby_version-$rvm_ruby_patch_level"
mkdir -p $rvm_ruby_source_dir
echo "$rvm_ruby_source_dir"
else
__rvm_log "fail" "No source directory exists for the default implementation."
fi
}
# clones from source implementation/version to current
function __rvm_gem-dup {
if [ "$1" = "default" ] ; then
rvm_source_gem_dir="$default_user_gem_path"
elif [ "$1" = "system" ] ; then
rvm_source_gem_dir="$default_system_gem_path"
else
rvm_source_gem_dir=${1:-$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_execute {
if [ -z "$rvm_selected" ] ; then __rvm_select $* ; fi
$rvm_ruby_home/bin/ruby $rvm_ruby_args
}
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
}
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)
rvm_action=$rvm_token
;;
use)
rvm_action=$rvm_token
if [ "$1" = "default" -o -z "$1" ] ; then
rvm_ruby_interpreter="system" ; shift
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) rvm_ruby_configure="$1" ; shift ;;
-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 ;;
--debug) rvm_debug=1 ;;
-m|--gem-set) rvm_gem_set_name="$1" ; shift ;;
--rm-gem-set) rvm_gem_set_name_rm="$1" ; shift ;;
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 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