bundler since v1.7当在 gemfile
中指定多个全局源时发出警告。您可以使用 source blocks指定哪些 gem 应该来自给定的来源,但是 source个别 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
没有。您不能在 .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
我是一名优秀的程序员,十分优秀!