Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to do after removing a gem from the Gemfile?

I removed a gem 'mygem' from the Gemfile, but just now I realized it's still installed.

So how do I tell bundler to rescan the Gemfile and update Gemfile.lock, without updating every gem?

Coming from php, this is how I'm used to do this: composer update nothing. Is there an equivalent for bundler?

like image 402
ChocoDeveloper Avatar asked Jul 22 '13 20:07

ChocoDeveloper


People also ask

Should a gem have a Gemfile lock?

The Gem Development guide says that the Gemfile. lock file "should always be checked into version control." However, this is NOT true for Gems. For Applications, like your Rails apps, Sinatra apps, etc., it is true. The same does not go for Gems.

What can you do with Gemfile?

Your gemfile is a list of all gems that you want to include in the project. It is used with bundler (also a gem) to install, update, remove and otherwise manage your used gems. These gems belong to development environment and the test environment since they are for testing the application.

How do you install gems you added to your Gemfile?

run the command bundle install in your shell, once you have your Gemfile created. This command will look your Gemfile and install the relevant Gems on the indicated versions. The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from.


1 Answers

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. It will not, however, remove the gem from your system. To do that, run gem uninstall mygem.

Not completely related, but still helpful:

  • bundle outdated will show you the gems that aren't on the latest version. Don't get too tied up with this list - it's fairly common to have gems that aren't on the latest version, because some gems are installed as dependencies & one gem might be requiring an older version of another gem.
  • bundle upgrade mygem will upgrade just that gem, and will bring its dependencies up to date. That means that other gems might be upgraded or installed as well.
  • You can search RubyGems to see a gem's dependencies across each of its versions. As a gem user, you'll only need to be concerned with the 'Runtime Dependencies' list at the bottom of the gem's page.
like image 187
James Chevalier Avatar answered Sep 21 '22 07:09

James Chevalier