Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to uninstall gems from a rails3 project?

I installed all of my gems using bundler via the Gemfile. I thought (mistakenly) that if I deleted a gem from my Gemfile and ran 'bundle install' that the deleted gems would be uninstalled. I've looked at the bundler help file and, so far as I can tell, it does not have a way to uninstall gems.

Do I just use gem uninstall x for everything? Is this going to confuse bundler?

like image 965
lashleigh Avatar asked Jan 12 '11 09:01

lashleigh


People also ask

How do I remove a gem from my project?

You can remove the Devise gem from your Gemfile and then run bundle install . The gem should then be removed. To be safe, you can also run the following: gem uninstall gem_name from the command line.

How do I remove gem from Gemfile lock?

You can run just bundle or bundle install to install gems based on your Gemfile. That will remove the instance of mygem from your Gemfile. lock file.


Video Answer


1 Answers

Bundler is launched from your app's root directory so it makes sure all needed gems are present to get your app working.If for some reason you no longer need a gem you'll have to run the

    gem uninstall gem_name  

as you stated above.So every time you run bundler it'll recheck dependencies

EDIT - 24.12.2014

I see that people keep coming to this question I decided to add a little something. The answer I gave was for the case when you maintain your gems global. Consider using a gem manager such as rbenv or rvm to keep sets of gems scoped to specific projects.

This means that no gems will be installed at a global level and therefore when you remove one from your project's Gemfile and rerun bundle then it, obviously, won't be loaded in your project. Then, you can run bundle clean (with the project dir) and it will remove from the system all those gems that were once installed from your Gemfile (in the same dir) but at this given time are no longer listed there.... long story short - it removes unused gems.

like image 168
Daniel Avatar answered Sep 28 '22 10:09

Daniel