从rails3项目中卸载gem的最佳方法是什么? [英] What is the best way to uninstall gems from a rails3 project?

查看:59
本文介绍了从rails3项目中卸载gem的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过Gemfile使用捆绑器安装了所有宝石。我以为(错误地)认为,如果我从自己的Gemfile中删除了一个gem,然后执行捆绑安装,则该已删除的gem将被卸载。我查看了捆绑软件帮助文件,据我所知,它没有卸载gems的方法。

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.

我是否只使用gem uninstall x进行所有操作?

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

推荐答案

捆绑程序从应用程序的根目录启动,这样可以确保所有必需的gem都存在。使您的应用正常运行。如果由于某种原因您不再需要gem,则必须运行

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

编辑-2014年12月24日

EDIT - 24.12.2014

我看到人们不断提出这个问题,因此我决定添加一些内容。
我的答案是在全球范围内维护宝石。考虑使用诸如rbenv或rvm之类的gem管理器,以使宝石组的范围限定于特定项目。

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.

这意味着不会在全局级别安装任何宝石,因此,您从项目的Gemfile中删除一个文件并重新运行捆绑包,那么显然不会将其加载到您的项目中。然后,您可以运行bundle clean(使用项目目录),它将从系统中删除曾经从Gemfile(位于同一目录中)安装的所有那些gem,但此时不再在其中列出...。长话短说-去除未使用的宝石。

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.

这篇关于从rails3项目中卸载gem的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆