-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathuninstall_gems
executable file
·56 lines (50 loc) · 1.08 KB
/
uninstall_gems
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
#!/usr/bin/env bash
#
# Originally from https://gist.github.com/IanVaughan/2902499
#
# authors: Ian Vaughan
# Jacob Zimmerman
#
# usage: uninstall_gems [<version> ...]
#
# examples:
# Uninstall all gems in all ruby version
# uninstall_gems
#
# Uninstall all gems in ruby 2.1.3
# uninstall_gems 2.1.3
#
# Uninstall all gems in the current ruby version
# uninstall_gems $(rbenv version-name)
uninstall() {
list=`gem list --no-versions`
for gem in $list; do
gem uninstall $gem -aIx
done
gem list
gem install bundler
}
if [ "$@" ]; then
RUBIES="$@"
else
#rbenv versions --bare
RBENVPATH=`rbenv root`
echo $RBENVPATH
RUBIES=`ls $RBENVPATH/versions`
fi
# Don't clobber existing .ruby-version file
if [ -f ./.ruby-version ]; then
RUBY_VERSION="$(cat ./.ruby-version)"
fi
for ruby in $RUBIES; do
echo '---------------------------------------'
echo $ruby
rbenv local $ruby
uninstall
done
# Restore old .ruby-version file if there was one
if [ "$RUBY_VERSION" ]; then
echo "$RUBY_VERSION" > ./.ruby-version
else
rm ./.ruby-version
fi