开发者

How to specify in Gemfile a .gemspec located in a subdirectory of a Git repository

开发者 https://www.devze.com 2023-02-28 18:33 出处:网络
I forked the spree repo on github and I would like to specify i开发者_如何学Pythonn the Gemfile of my rails app a gem that is located in the core subdirectory of the main repository.

I forked the spree repo on github and I would like to specify i开发者_如何学Pythonn the Gemfile of my rails app a gem that is located in the core subdirectory of the main repository.

The folder structure of the repository is the following:

|~spree                   [git root]
| |-spree.gemspec         [spree gem located here]
|~core
| |-spree_core.gemspec    [spree_core gem located here]

In other words, I would like to do something along these lines:

gem 'spree-core', :git => 'git://github.com/spree/spree.git'

The problem is that I'm getting the following error message when I try bundle install:

Could not find gem 'spree-core (>= 0)' in git://github.com/spree/spree.git (at master). Source does not contain any versions of 'spree-core (>= 0)'


What you can do is create a repo that only contains the core subdirectory and associated spree_core.gemspec file. This will lead to a slimmer installation as well. You can also grab the contents of the directory to bundle with your app and distribute it like this:

gem 'spree-core', :path => 'vendor/gems/spree/core'

The ability of bundler to install from a git repository appears to be somewhat limited according to the documentation where it is expecting spree_core/spree_core.gemspec and not core/spree_core.gemspec instead.

This oversight on the part of the gem creator is common since most do not expect people to be installing anything other than the officially published gem. At least it's nice that the .gemspec file is available as some projects don't even include that much to the dismay of many.


This came up first on a google search and the answer given either was never correct or Bundler's changed it's behaviour.

In the OP there was a spelling mistake and the error seems consistent with that being the original problem. Specifically spree-core should not have been hyphenated.

The following should work fine:

gem 'spree_core', github: 'spree/spree'
0

精彩评论

暂无评论...
验证码 换一张
取 消