Instantly share code, notes, and snippets.

Embed
What would you like to do?
Uninstall all rbenv gems
#!/usr/bin/env bash
uninstall() {
list=`gem list --no-versions`
for gem in $list; do
gem uninstall $gem -aIx
done
gem list
gem install bundler
}
#rbenv versions --bare
RBENVPATH=`rbenv root`
echo $RBENVPATH
RUBIES=`ls $RBENVPATH/versions`
for ruby in $RUBIES; do
echo '---------------------------------------'
echo $ruby
rbenv local $ruby
uninstall
done
@PhilT

This comment has been minimized.

Copy link

PhilT commented Jul 31, 2013

Nice script!

Was looking for something like this. Gave me a surprise when I saw who wrote it!

Just used it. Works great!

@PhilT

This comment has been minimized.

Copy link

PhilT commented Jul 31, 2013

You might want to add "are you sure you want to remove everything?"!

@danielalvarenga

This comment has been minimized.

Copy link

danielalvarenga commented Nov 20, 2013

Muito bom!

@exalted

This comment has been minimized.

Copy link

exalted commented Feb 20, 2014

This leaves .ruby-version in the current folder when it's done?

@reicheltd

This comment has been minimized.

Copy link

reicheltd commented Mar 20, 2014

works! thx

@futhr

This comment has been minimized.

Copy link

futhr commented Oct 15, 2014

Perfect, thx!

@jez

This comment has been minimized.

Copy link

jez commented Dec 21, 2014

I wrote an updated version that addresses the .ruby-version issue and also allows you to specify a list of ruby versions whose gems should be installed as command line args:

https://gist.github.com/jez/cc2ba08062c6183a489c

@yourivdlans

This comment has been minimized.

Copy link

yourivdlans commented Feb 4, 2015

The above link doesn't seem to work :(

@jez

This comment has been minimized.

Copy link

jez commented Apr 19, 2015

Sorry about that, I had changed my GitHub username. It should be fixed now.

@dsapandora

This comment has been minimized.

Copy link

dsapandora commented Jun 26, 2015

Works great for me. Thanks!!

@wellington1993

This comment has been minimized.

Copy link

wellington1993 commented Mar 23, 2016

Legal! Cool!

@ThinkTankShark

This comment has been minimized.

Copy link

ThinkTankShark commented Apr 20, 2016

Amazing script. Thanks!

@denislins

This comment has been minimized.

Copy link

denislins commented Jun 21, 2016

+99

@antnruban

This comment has been minimized.

Copy link

antnruban commented Aug 18, 2016

Works great!! Thanks a lot!

@agrimm

This comment has been minimized.

Copy link

agrimm commented Feb 8, 2017

This is a great script. However, there's a minor hiccup: I got

ERROR:  While executing gem ... (Gem::InstallError)
    gem "bigdecimal" cannot be uninstalled because it is a default gem

Is there a fork that addresses this?

@lacostenycoder

This comment has been minimized.

Copy link

lacostenycoder commented Apr 4, 2017

Nice one! I just wanted to remove one gem prefix for all ruby versions and was easy with this.
Just modified

list=`gem list --no-versions`

to

list=`gem list my_stupid_gem_prefix --no-versions`

Works great, thanks!

@b264

This comment has been minimized.

Copy link

b264 commented Jun 20, 2017

this== greatness

@florestankorp

This comment has been minimized.

Copy link

florestankorp commented Oct 8, 2017

Wow, thanks for this script!

@konstantin0s

This comment has been minimized.

Copy link

konstantin0s commented Oct 12, 2017

I am new to Ubuntu and I want to know how do you run this script. Any suggestions?

@ymsr5612

This comment has been minimized.

Copy link

ymsr5612 commented Jan 14, 2018

Works Thanks! Nice Script!

@marioabreu

This comment has been minimized.

Copy link

marioabreu commented Mar 28, 2018

cool 👍

@charlesdebarros

This comment has been minimized.

Copy link

charlesdebarros commented Oct 22, 2018

You are a life-saver. Thank you.
:)

@charlesdebarros

This comment has been minimized.

Copy link

charlesdebarros commented Oct 22, 2018

I am new to Ubuntu and I want to know how do you run this script. Any suggestions?
@konstantin0s
I am sure you may have found the solution by now but just in case, check this:
https://askubuntu.com/questions/38661/how-do-i-run-sh-files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment