问题描述
正式文档中描述的内容有些复杂。
The things described in the formal documentation are a bit complicated.
是否仅将以下行添加到 .bundle / config code>
Does it merely add the following line to .bundle/config
BUNDLE_PATH: vendor/bundle
然后执行捆绑安装,就是这样吗? (然后安装会将所有gem都安装到供应商/捆绑包中)
and then perform a bundle install, and that's it? (install will then install all the gems into vendor/bundle)
然后,当应用程序运行时,它将看起来在 .bundle / config 中指定的该路径中的宝石,就是这样吗?
Then when the application runs, it will look for the gems in this path specified in .bundle/config, and that's it?
更新:如果我使用Mercurial(类似于Git)来跟踪项目中的文件,那么在执行捆绑安装--deployment 之后,唯一的变化是向供应商/捆绑添加了许多文件,并向 .bundle / config 添加了2行:
Update: if I use Mercurial (similar to Git) to keep track of files in project, then after doing the bundle install --deployment, the only changes are a lot of files added to vendor/bundle, and 2 lines added to .bundle/config:
BUNDLE_FROZEN: "1" BUNDLE_PATH: vendor/bundle
推荐答案
捆绑安装--deployment 确实确实在本地将宝石安装到供应商/捆绑目录中的应用程序。您提到的路径设置(BUNDLE_PATH:供应商/捆绑)中的配置更改反映了这一点。这种方法称为冻结或供应 gem,它迫使应用程序使用本地安装的gem,而不是全局系统gem,这是部署时的便利默认设置。如捆绑程序文档中所述:
bundle install --deployment does indeed install the gems locally to the vendor/bundle directory in the application. This is reflected by the config change in the path setting which you mentioned (BUNDLE_PATH: vendor/bundle). This approach is known as "freezing" or "vendoring" the gems and it forces the application to use the locally installed gems, rather than the global system gems,which is convenient default for deployment. As mentioned in bundler documentation:
在部署中,隔离是更重要的默认设置。此外,部署应用程序的用户可能没有
有权在系统中安装
宝石,或者Web服务器可能没有权限让
读取它们。
这篇关于Rails 3的Bundler“捆绑安装-部署”功能是什么?到底是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!