What to do after removing a gem from the Gemfile?

喜夏-厌秋 提交于 2020-05-11 03:45:07

问题


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?


回答1:


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.



回答2:


Cleans up unused gems in your bundler directory: bundle clean --force



来源:https://stackoverflow.com/questions/17796367/what-to-do-after-removing-a-gem-from-the-gemfile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!