uninstall dependencies along with the gem

I installed spree by adding it in gemfile. It was giving me errors, so I went to the github site, and installed spree using “gem install spree”. But now it looks like i have two sets of gems for the dependencies of spree:

spree_api (2.0.3, 0.40.0) spree_auth (0.40.0) spree_backend (2.0.3) spree_cmd (2.0.3) spree_core (2.0.3, 0.40.0) spree_dash (0.40.0) spree_frontend (2.0.3) spree_promo (0.40.0) spree_sample (2.0.3, 0.40.0)

How do I uninstall spree and all of the gems that were installed along with it?

I can see it being quite dangerous to uninstall all dependancies of a given gem. In theory it could be dependant on gems which have become part of the core library in more recent Ruby versions, for example.

However if you mean you want to keep only the latest version of each gem, there's the "gem clean" command.

Also there are other dangers. Let’s assume an RSS-Feed-Gem wich depends on Nokogiri. Also you have a rails app which depends on Nokogiri.

Now you remove that RSS-Gem and your App suddenly stops working. Ok, that is as easy as bundle command but creates unnecessary traffic and consumes time.

No need, it does not matter if additional ones are installed. The versions defined in Gemfile and hence Gemfile.lock are the ones that will be used by the app. If you feel you must remove them however then [1] describes how to remove a particular version of a gem.

[1] http://docs.rubygems.org/read/chapter/10#page38

Colin

This is an extreme assumption that somehow blindly implies that dependency resolving does not and probably won't exist if this feature exists. My refute to that is: apt. Just because you remove one gem and another relies on a dependency the removed relied on does not mean you cannot resolve dependencies and figure out if it's still needed by another gem, as a matter of fact, bundler already has most of that built into it and on tap, it just needs to be reworked a bit and presto, you have an apt like resolver.

Assuming you’re working in bash:

for gem in $(gem list spree --no-versions); do

echo “working on $gem”

gem uninstall $gem

done

“gem uninstall” asks you if you really want to uninstall if there are dependencies.

But there are a lot of third-party dependencies that spree needed, and installed. Want to just clean up everything that you don’t use and start over again with your system gemset? Do the same without the spree filter. It’ll uninstall everything that doesn’t have a dependency without asking, and ask you if it does.

for gem in $(gem list --no-versions); do

echo “working on $gem”

gem uninstall $gem

done

–Ivan

Since gem does only look at installed gems and there is no flag like apts "installed manually" and bundler does only recognize dependencies on a per project basis, my scenario is valid with the current architecture.

Since gem does only look at installed gems and there is no flag like apts “installed manually” and bundler does only recognize dependencies on a per project basis, my scenario is valid with the current architecture.