Bundler不会安装我的gem的依赖项

时间:2019-06-06 13:25:32

标签: ruby-on-rails ruby rubygems dependencies bundler

我用gemspec创建了一个宝石:

# frozen_string_literal: true

Gem::Specification.new do |s|
  s.name           = 'my_gem'
  s.version        = '0.0.1'
  s.date           = '2019-05-31'
  s.summary        = 'summary'
  s.description    = 'description'
  s.authors        = ['my name']
  s.email          = 'my@email.com'
  s.files          = Dir['{lib}/**/*.rb', 'bin/*', '*.md']
  s.require_path   = 'lib'
  s.executables    = ['some_bin']
  s.homepage       = 'https://some.homepage.com'
  s.license        = 'MIT'
  s.add_dependency 'hidapi', '= 0.1.9'
end

我希望在将我的gem添加到Gemfile之后,捆绑程序不仅会安装my_gem,还会安装依赖项,即hidapi。但是,当我尝试运行rails s时出现错误。

Traceback (most recent call last):
bin/rails: Bootsnap::LoadPathCache::FallbackScan
(...)
kernel_require.rb:22:in `require': cannot load such file -- hidapi (LoadError)

在Gemfile.lock中,my_gem没有任何依赖性。我想念什么?

解决方案

我认为捆绑程序仅使用gemspec,但看起来它使用了我的gem的Gemfile。我的gemfile也具有所有依赖关系,但应直接要求gemspec。它应该看起来像这样:

# frozen_string_literal: true

source 'https://rubygems.org'

gemspec

我什至不知道source 'https://rubygems.org'是否必要。

0 个答案:

没有答案
相关问题