I was in my rails3 gemset for a project, and accidentally switched to the rails4 branch of the project without also switching to the rails4 gemset.
I bundle installed and then my gemset was dirty with Rails4 gems and binaries.
How do you clean out and start over?
This old link offered panache: http://geekystuff.net/2009/01/14/remove-all-ruby-gems/
But it didn't work.
There are a lot of gems which can't be removed (I am using rvm here) and the old trick doesn't work. I know rvm, or JewelryBox?, has a tool to cleanout a gemset, but I wanted to do it myself.
Here is a way to do it, as of Ruby 2.1.2 with rvm on Mac OS 10.9.3 (please someone give me a better alternative!):
gem list | grep -v "test-unit" | grep -v "psych" | grep -v "rdoc" | grep -v "io-console" | grep -v "minitest" | grep -v "gem-wrappers" | grep -v "executable-hooks" | grep -v "rake" | grep -v "bundler-unload" | grep -v "bundler" | grep -v "bigdecimal" | grep -v "json" | cut -d" " -f1 | xargs gem uninstall -aIx
I tried using
grep -P to combine the exclusions in a single regex but it seems to not be implemented.