Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails bundle clean

After updating a bundle, you will have some gems that may be obsolete -- since a newer version of that gem has been installed. There is no such command under the bundle executable i.e. bundle clean. How does one get rid of these obsolete gems?

This is an attempt to reduce slug size in my rails app.

like image 903
Igbanam Avatar asked Oct 26 '11 15:10

Igbanam


2 Answers

If you are using Bundler 1.1 or later you can use bundle clean, just as you imagined you could. This is redundant if you're using bundle install --path (Bundler manages the location you specified with --path, so takes responsibility for removing outdated gems), but if you've used Bundler to install the gems as system gems then bundle clean --force will delete any system gems not required by your Gemfile. Blindingly obvious caveat: don't do this if you have other apps that rely on system gems that aren't in your Gemfile!

Pat Shaughnessy has a good description of bundle clean and other new additions in bundler 1.1.

like image 173
David Waller Avatar answered Sep 25 '22 12:09

David Waller


If you're using RVM you may use rvm gemset empty for the current gemset - this command will remove all gems installed to the current gemset (gemset itself will stay in place). Then run bundle install in order to install actual versions of gems. Also be sure that you do not delete such general gems as rake, bundler and so on during rvm gemset empty (if it is the case then install them manually via gem install prior to bundle install).

like image 33
trushkevich Avatar answered Sep 25 '22 12:09

trushkevich