简体   繁体   English

rake rails之间有什么区别:freeze:gems和rake gems:unpack?

[英]What is the difference between rake rails:freeze:gems and rake gems:unpack?

As far as I know both rails:freeze:gems and rake gems:unpack are placing the gems to /vendor . 据我所知,两个rails:freeze:gems和rake gems:unpack将gems放到/vendor rails:freeze:gems places them to /vendor/rails , gems:unpack place them to /vendor/gems . rails:freeze:gems将它们放到/vendor/railsgems:unpack将它们放到/vendor/gems The point for me seems to be the same, however. 然而,对我来说,这一点似乎是一样的。 In both cases the goal is to fix the gems and their versions as they were during the development. 在这两种情况下,目标都是在开发过程中修复宝石及其版本。 Is there any other difference? 还有其他区别吗? It seems to me a duplication now.. 在我看来现在重复..

From my understanding, gem:unpack will unpack any third party gem your app needs into vendor/gems. 根据我的理解,gem:unpack会将您的应用所需的任何第三方宝石解压缩到供应商/宝石中。
rails:freeze:gems freezes only those gems having to do with rails itself, so it freezes your app to a specific version of rails. rails:freeze:gems只冻结那些与rails本身有关的gem,因此它会将你的应用程序冻结到特定版本的rails。 Thus the different /vendor/rails directory. 因此不同的/ vendor / rails目录。

To comment a bit more: 再评论一下:
There's this line in config/environment.rb config / environment.rb中有这一行
# Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION

So by default, rails will check to see if the vendor/rails directory exists, and use the versions of those gems if it does. 因此,默认情况下,rails将检查vendor / rails目录是否存在,如果存在则使用这些gem的版本。 If not, you must set which version of rails it will use, and rails will try to pull in the gems from your local system. 如果没有,您必须设置它将使用哪个版本的rails,rails将尝试从本地系统中提取gem。

So the only difference between the two commands I see is that rails:freeze:gems dumps ONLY the rails files into vendor/rails, which is exactly where rails wants them to be. 所以我看到的两个命令之间的唯一区别就是rails:freeze:gems只将rails文件转储到vendor / rails,这正是rails想要的那些。

The reason you want to use gem:unpack is to dump third party gems your application depends on, so wherever your app is run those gems won't need to be installed locally. 您想要使用gem:unpack的原因是转储您的应用程序所依赖的第三方宝石,因此无论您的应用运行在何处,都不需要在本地安装这些宝石。

You can think of rails:freeze:gems as a shortcut that simply does a gem:unpack of only the rails gems into the directory rails expects (/vendor/rails), so that you don't have to manually do it. 你可以想到rails:freeze:gems作为一个简单地执行gem:unpack的快捷方式gem:unpack只将rails gems gem:unpack到rails期望的目录(/ vendor / rails),这样你就不必手动执行了。 But yes, behind the scenes I expect rails:freeze:gems probably uses gem:unpack 但是,在幕后我期待rails:freeze:gems可能使用gem:unpack

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM