如何为 gemspec 中声明的依赖项指定源



捆绑器,因为 v1.7 在gemfile中指定多个全局源时发出警告。您可以使用源块来指定哪些 gem 应来自给定源,但单个 gem 的源选项在 gemspec 中不起作用。

如何在 gemspec 中指定依赖项的来源? 例如

Gem::Specification.new do |s|
  # Gemspec contents omitted for brevity 
  # Lets say this one comes from RubyGems.org 
  s.add_runtime_dependency 'aruntimedep', '~> 1.0'
  # And this one needs to be sourced from a private gem server
  s.add_development_dependency 'adevdep',  '~> 3.0'
  # Note, Bundler throws an error in this case
  # s.add_development_dependency 'adevdep',  '~> 3.0', :source => "mygemserver.org"
end 

No.不能在.gemspec文件中指定源。

要尝试使其工作,您可以执行以下操作:

#Gemfile
source 'https://rubygems.org'
source 'https://mygemserver.org' do
   gem 'adevdep'
end
#gemspec
Gem::Specification.new do |s|
  # Lets say this one comes from RubyGems.org 
  s.add_runtime_dependency 'aruntimedep', '~> 1.0'
  s.add_development_dependency 'adevdep', '~> 0.2'
end

查看报告的问题:https://github.com/bundler/bundler/issues/3576

最新更新