在运行时找不到自定义安装的gem

prdp8dxp  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(395)

在rhel8上,我构建并安装了一个定制的gem test1 .

$ gem build test1.gemspec
  Successfully built RubyGem
  Name: test1
  Version: 0.0.1
  File: test1-0.0.1.gem
$ gem install test1-0.0.1.gem
Successfully installed test1-0.0.1
1 gem installed

# check if gem is installed. All gems are installed in this path

$ gem which test1
/usr/local/share/gems/gems/test1-0.0.1/lib/test1.rb

现在,在我构建的另一个自定义gem中,gempec文件如下所示:


# in test2.gemspec file

Gem::Specification.new do |spec|
  spec.name          = "test2"
  ...

  spec.add_runtime_dependency "test1", "0.0.1"
  ...
end

当我尝试安装test2 gem时,它失败了,并说它找不到已经安装的test1 gem。这个问题开始发生在rhel8上。我在debian和alpine上进行了测试,发现和安装gem没有问题。

$ gem build test2.gemspec
  Successfully built RubyGem
  Name: test2
  Version: 0.0.1
  File: test2-0.0.1.gem
$ gem install test2-0.0.1.gem
ERROR:  Could not find a valid gem 'test1' (= 0.0.1) in any repository

如果我换成 add_development_dependency ,它构建并安装gem。图像按预期工作,没有任何问题。有人知道为什么当我添加时它找不到宝石吗 add_runtime_dependency ?

ddrv8njm

ddrv8njm1#

如果您正在构建一个需要另一个私有gem的私有gem,则需要在 gemspecGemfile ,同时在 Gemfile .
例如,我们使用gemfury托管私有宝石,然后在需要该私有宝石的任何其他宝石中,我们执行以下操作:


# Gemfile

source 'https://gem.fury.io/your-user/' do
  gem 'your-gem'
end

gemspec

# your-gem.gemspec

s.add_runtime_dependency 'your-gem', '0.0.1'

相关问题