Bundler's:在gemfile中需要选项?

时间:2014-02-25 02:00:03

标签: ruby sinatra bundler base

如何在gemspec中使用B​​undler的:require=>?例如,我想只使用sinatra / base作为运行时依赖项。这适用于gemfile:

gem 'sinatra', :require => 'sinatra/base'

但在gemspec中不起作用(即使gemspec中需要打包器):

s.add_runtime_dependency 'sintatra', :require => 'sinatra/base'

错误是“格式错误的要求[{:require =>”sinatra / base“}]”

还有其他人发现自己处于类似情况吗?

1 个答案:

答案 0 :(得分:0)

在gemspec文件中,您只能指定gem的依赖项。这个文件不需要你。你应该在ruby代码中要求依赖。

另一方面,您可以创建一个Gemfile来帮助您进入开发环境。但是当你在其他项目中使用gem时,不会加载Gemfile。