It seems that ruby 2.0.0 has added "default" gems to the mix and makes them non removable by gem uninstall.
How can you remove all non default gems?
It seems that ruby 2.0.0 has added "default" gems to the mix and makes them non removable by gem uninstall.
How can you remove all non default gems?
I used this one line script.
for i in `gem list --no-versions`; do gem uninstall -aIx $i; done
It ignores default gem errors and just proceeds. Simple and self-evident.
set +e
and try again. –
Krupp gem list --no-version | awk 'NR>1{ print $(NF-1) }' | xargs gem 2>/dev/null uninstall -aIx
it doesn't error but it also doesn't uninstall the gems. I assume the command still stops executing when error occurs (even if it gets redirected) –
Ultravirus for i in $(gem list --no-versions); gem uninstall -aIx $i
. –
Pharyngology First, go to the gems directory
Like ../ruby/2.0.0-p195/lib/ruby/gems/2.0.0/specifications
You will find a directory named default, which including all the default gems shipped with ruby 2.0
Move all the *.gemspec stored in default dir to specifications dir and remove the empty default dir.
Then you can do whatever you want like old days.:-)
I wrote a script in ruby to remove all non default gems.
https://gist.github.com/nixpulvis/5042764
This is needed now because unlike before 2.0.0 some gems are labeled "default" with the installation of ruby, and cannot be uninstalled with gem uninstall
. This makes the previously popular methods for deleting all gems not work.
For reference here it is.
gem list | cut -d" " -f1 | xargs gem uninstall
I have not yet found a better answer than to exclude the "default" gems:
/usr/local/bin/gem list --no-versions | \
grep -v -E "(bigdecimal|io-console|json|minitest|psych|rake|rdoc|test-unit)" | \
xargs --no-run-if-empty /usr/local/bin/gem uninstall --executables --user-install --all --force
© 2022 - 2024 — McMap. All rights reserved.
rvm
?) – Announcegem uninstall json
errors with gem "json" cannot be uninstalled because it is a default gem. – Countersigngem cleanup
? – Announcervm
has gemsets, not sure aboutrbenv
– Announcervm
orrbenv
. But I agree if I hasrvm
a simplervm gemset empty
would do :) – Countersign