Ruby-on-rails 导轨捆绑清洁
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7905114/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
rails bundle clean
提问by iGbanam
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 bundleexecutable i.e. bundle clean. How does one get rid of these obsolete gems?
更新包后,您将拥有一些可能已过时的 gem - 因为已经安装了该 gem 的较新版本。bundle可执行文件 ie下没有这样的命令bundle clean。如何摆脱这些过时的宝石?
This is an attempt to reduce slug size in my rails app.
这是在我的 rails 应用程序中减少 slug 大小的尝试。
回答by David Waller
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 --forcewill 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!
如果您使用的是 Bundler 1.1 或更高版本,则可以使用bundle clean,就像您想象的那样。如果您正在使用,这是多余的bundle install --path(Bundler 管理您使用 --path 指定的位置,因此负责删除过时的 gem),但是如果您使用 Bundler 将 gem 安装为系统 gem,那么bundle clean --force将删除任何系统 gem你的 Gemfile 需要。非常明显的警告:如果您有其他应用程序依赖于不在您的 Gemfile 中的系统 gem,请不要这样做!
Pat Shaughnessy has a good description of bundle cleanand other new additions in bundler 1.1.
Pat Shaughnessybundle clean对 bundler 1.1 中的其他新增功能有很好的描述。
回答by trushkevich
If you're using RVM you may use rvm gemset emptyfor the current gemset - this command will remove all gems installed to the current gemset (gemset itself will stay in place). Then run bundle installin 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 installprior to bundle install).
如果您使用的是 RVM,则可以rvm gemset empty用于当前 gemset - 此命令将删除安装到当前 gemset 的所有 gem(gemset 本身将保留在原位)。然后运行bundle install以安装 gems 的实际版本。另外要确保你不删除这些一般的宝石如耙,捆绑等过程中rvm gemset empty(如果是的话,那么通过手动安装它们gem install之前bundle install)。
回答by Pan Thomakos
If you are using RVM you can install your gems into gemsets. That way when you want to perform a full cleanup you can simply remove the gemset, which in turn removes all the gems installed in it. Your other option is to simply uninstall your unused gems and re-run your bundle installcommand.
如果您使用的是 RVM,您可以将您的 gems 安装到gemsets 中。这样,当您想要执行完全清理时,您可以简单地删除 gemset,从而删除安装在其中的所有 gem。您的另一个选择是简单地卸载未使用的 gem 并重新运行您的bundle install命令。
Since bundler is meant to be a project-per-project gem versioning tool it does not provide a bundle cleancommand. Doing so would mean the possibility of removing gems associated with other projects as well, which would not be desirable. That means that bundler is probably the wrong tool to use to manage your gem directory. My personal recommendation would be to use RVM gemsets to sandbox your gems in certain projects or ruby versions.
由于 bundler 旨在成为每个项目的 gem 版本控制工具,因此它不提供bundle clean命令。这样做意味着也有可能删除与其他项目相关的 gem,这是不可取的。这意味着 bundler 可能是用于管理 gem 目录的错误工具。我个人的建议是使用 RVM gemsets 在某些项目或 ruby 版本中沙箱你的 gems。
回答by Tyler Brock
Honestly, I had problems with bundler circular dependencies and the best way to go is rm -rf .bundle. Save yourselves the headache and just use the hammer.
老实说,我遇到了 bundler 循环依赖的问题,最好的方法是rm -rf .bundle. 省去头疼的麻烦,只需使用锤子即可。
回答by JJD
When searching for an answer to the very same question I came across gem_unused.
You also might wanna read this article: http://chill.manilla.com/2012/12/31/clean-up-your-dirty-gemsets/
The source code is available on GitHub: https://github.com/apolzon/gem_unused
在寻找同一问题的答案时,我遇到了gem_unused。
您可能还想阅读这篇文章:http: //chill.manilla.com/2012/12/31/clean-up-your-dirty-gemsets/
源代码可在 GitHub 上找到:https: //github.com/ apolzon/gem_unused
回答by Leonid Shevtsov
I assume you install gems into vendor/bundle? If so, why not just delete all the gems and do a clean bundle install?
我假设您将 gems 安装到vendor/bundle? 如果是这样,为什么不删除所有宝石并进行清理bundle install?
回答by Gareth
Just remove the obsolete gems from your Gemfile. If you're talking about Heroku (you didn't mention that) then the slug is compiled each new release, just using the current contents of that file.
只需从您的 Gemfile 中删除过时的 gem。如果您在谈论 Heroku(您没有提到),那么每个新版本都会编译 slug,只使用该文件的当前内容。
回答by codevb
Just execute, to clean gems obsolete and remove print warningns after bundle.
只需执行,清理过时的 gems 并在捆绑后删除打印警告。
bundle clean --force

