问题描述
我正在研究一个宝石(宝石A),它使用了我也写过的另一个宝石(宝石B)。到目前为止,宝石B已添加到宝石A的gemspec中:
I am working on a gem (Gem A) which uses another gem (Gem B) that I have also written. Until this point Gem B has been added in the gemspec for Gem A:
gem.add_dependency "gem_a", "~> 0.0.4"
但是我现在发现需要使用本地版本进行调试。
But I now find the need to debug using my local version.
要在Gemfile中声明本地依赖项,我可以这样做:
To declare a local dependency in a Gemfile I could do:
gem 'gem_a', path: "/local/path/to/gem_a"
但是我该怎么办在 .gemspec
中声明本地依赖项?
But how do I declare a local dependency in a .gemspec
?
推荐答案
这样人们就可以更快地找到答案了……
Just so folks can find the answer (slightly) faster...
如果您要创建gem,并且需要在开发过程中添加本地依赖项,在您的 gem的 Gemfile中,执行以下操作:
If you're creating a gem, and need to add a local dependency (while developing), in your gem's Gemfile, do something like:
source 'https://rubygems.org'
# Specify your gem's dependencies in mygem.gemspec
gemspec
gem "local_gem", path: "/path/to/local_gem"
当您捆绑包
时,您会看到它现在正在使用本地路径
When you bundle
you should see it's now using the local path
Using local_gem 0.1.0 from source at `/path/to/local_gem`
这篇关于Gem .gemspec中的局部依赖性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!