I'm in the process of creating a Gem the requires other Gems to be installed on the user's system. I'm doing the traditional thing and specifying my dependencies in my Gemfile
for bundle install
to recognize.
我正在创建一个Gem,需要在用户的系统上安装其他Gems。我正在做传统的事情,并在我的Gemfile中指定我的依赖项以进行bundle install以识别。
It looks like the Gem specification file has a way to specific dependencies as well via:
看起来Gem规范文件也可以通过以下方式获取特定的依赖关系:
Gem::Specification do |s|
s.add_runtime_dependency...
s.add_development_dependency...
end
How do I avoid specifying my dependencies in both places?
如何避免在两个地方指定我的依赖项?
1 个解决方案
#1
0
In your Gemfile:
在你的Gemfile中:
#!/usr/bin/env ruby
gemspec
In your .gemspec:
在.gemspec中:
Gem::Specification do |s|
s.add_runtime_dependency('some-gem-for-production', '>= 3.0.0')
s.add_development_dependency('some-gem-for-development', '>= 2.0.0')
end
Now when you run bundle install
the Gemfile tells bundle
to look in your Gem Specification file for dependencies.
现在,当您运行bundle install时,Gemfile会告诉bundle在您的Gem Specification文件中查找依赖项。
#1
0
In your Gemfile:
在你的Gemfile中:
#!/usr/bin/env ruby
gemspec
In your .gemspec:
在.gemspec中:
Gem::Specification do |s|
s.add_runtime_dependency('some-gem-for-production', '>= 3.0.0')
s.add_development_dependency('some-gem-for-development', '>= 2.0.0')
end
Now when you run bundle install
the Gemfile tells bundle
to look in your Gem Specification file for dependencies.
现在,当您运行bundle install时,Gemfile会告诉bundle在您的Gem Specification文件中查找依赖项。