'require bundler'和'require bundler / setup'之间的区别 [英] Difference between 'require bundler' and 'require bundler/setup'

查看:97
本文介绍了'require bundler'和'require bundler / setup'之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用

require 'bundler/setup' 

我不支持 Bundler.with_clean_env

但是当我将其更改为

require 'bundler' 

它支持 Bundler.with_clean_env 。引起困惑的是,要求'bundler''bundler / setup'有什么区别?

It supports Bundler.with_clean_env. The confusion that rises here is what is the difference between requiring 'bundler' and 'bundler/setup'?

推荐答案

在提到宝石时,要求'foo'将需要 foo.rb 文件位于gem的 lib 目录中。该文件通常与gem具有相同的名称,并负责要求其他所有必需文件以使gem起作用。

When referring to gems, require 'foo' would require the foo.rb file that is located in the gem's lib directory. That file has usually the same name as the gem and is responsible for requiring all other necessary files for the gem to function.

当您执行时, 'foo / bar',则搜索 lib / foo / bar.rb 。换句话说,您只需要一个特定的文件从那个宝石,而不是整个事情。

When you do require 'foo/bar', you search for lib/foo/bar.rb. In other words, you require only a specific file from that gem and not the whole thing.

bundler / setup 负责加载所有描述的宝石在您的Gemfile中。 Bundler.with_clean_env 是完全不同的功能,已定义在宝石的主文件中。

The bundler/setup is responsible for loading all gems described in your Gemfile. Bundler.with_clean_env is a completely different functionality, defined in the gem's main file.

这篇关于'require bundler'和'require bundler / setup'之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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