您的 Gemfile 中的 gem 顺序是否有所不同? [英] Does the order of gems in your Gemfile make a difference?

查看:48
本文介绍了您的 Gemfile 中的 gem 顺序是否有所不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您列出宝石的顺序重要吗?这两个块是等价的吗?

gem 'carrierwave'宝石 'rmagick'

gem 'rmagick'宝石载波"

解决方案

当您使用 Bundle.require(Rails 这样做)时,需要按照它们在 Gemfile 中出现的顺序来使用 Gems.并不总是这样,但一直这样.>

由于 Carrierwave 在需要时明确要求 RMagick,所以我认为这对您的情况不重要;但严格来说这两个块并不等价.

Is the order in which you list your gems important? Are these two blocks equivalent?

gem 'carrierwave'
gem 'rmagick'

And

gem 'rmagick'
gem 'carrierwave'

解决方案

When you use Bundle.require (which Rails does), Gems are required in the order they appear in the Gemfile. In wasn’t always like this, but has been this way for a while.

Since Carrierwave requires RMagick explicitly when it is needed, I don’t think it should matter in your case; but strictly speaking the two blocks are not equivalent.

这篇关于您的 Gemfile 中的 gem 顺序是否有所不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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