简体   繁体   English

Gem .gemspec中的局部依赖性

[英]Local Dependency in Gem .gemspec

I am working on a gem (Gem A) which uses another gem (Gem B) that I have also written. 我正在研究一种宝石(宝石A),它使用了我也写过的另一种宝石(宝石B)。 Until this point Gem B has been added in the gemspec for Gem A: 在此之前,Gem B已添加到Gem A的gemspec中:

gem.add_dependency "gem_a", "~> 0.0.4"

But I now find the need to debug using my local version. 但我现在发现需要使用我的本地版本进行调试。

To declare a local dependency in a Gemfile I could do: 要在Gemfile中声明本地依赖项,我可以这样做:

gem 'gem_a', path: "/local/path/to/gem_a"

But how do I declare a local dependency in a .gemspec ? 但是如何在.gemspec声明本地依赖?

Just so folks can find the answer (slightly) faster... 只是这样人们可以更快地找到答案(略微)

If you're creating a gem, and need to add a local dependency (while developing), in your gem's Gemfile, do something like: 如果您正在创建一个gem,并且需要添加一个本地依赖项(在开发时),请在gem的 Gemfile中执行以下操作:

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 bundle您应该看到它现在使用本地路径

Using local_gem 0.1.0 from source at `/path/to/local_gem`

Hm...what about adding it in gem's Gemfile in :development group? 嗯...如何在gem的Gemfile中添加它:development组?

UPD: I found similar question, maybe this helps UPD:我发现了类似的问题,也许这有帮助

How to add dependency of a local gem to a rails plugin/engine, in .gemspec file 如何在.gemspec文件中将本地gem的依赖项添加到rails插件/引擎

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM