Ruby Gemspec Dependency: Is possible have a git branch dependency?

前端 未结 4 1618
慢半拍i
慢半拍i 2020-12-08 03:51

Is possible have a git branch dependency, inside mygem.gemspec?

I\'m thinking something similar to the following:

gem.add_runtime_dependency \'oauth2         


        
4条回答
  •  悲哀的现实
    2020-12-08 04:38

    I just was trying to figure this problem out as well. And I just came up with the following solution (which I'm not sure if your publishing your gem or have rights to redistribute that oauth2 gem).

    In your gem that requires oauth2 gem run this.

    git submodule add git@github.com:lgs/oauth2.git lib/oauth2
    

    If you require a different branch than the default

    cd lib/oauth2 && git checkout 
    cd .. && git add lib/oauth2
    git commit -m "adding outh2 submodule"
    

    In your gemspec add this above your require version line

    $:.push File.expand_path('../lib/oauth2/lib', __FILE__)
    

    Also you'll need to add all of the oauth2 gem's runtime dependencies to your gemspec. I haven't figured out a way around this yet.

    This is what I did, and it works for us because our gem is required via git so I'm not sure if this would work for a rubygems published gem.

提交回复
热议问题