【发布时间】:2021-10-08 13:41:15
【问题描述】:
我有一个 Bundler 设置,其中一个 gem 是从一个私有源(存储库)下载的,它通过一个环境变量进行身份验证。
这是宝石准备工作流程:
$ export MYKEY=key
$ cat >> Gemfile <<EOF
source "https://private.repository.com/" do
gem 'mygem'
end
EOF
$ bundle package
这将获取 Gemfile 的所有 gem,并将它们存储在 vendor/cache 下;这包括宝石mygem。
我想直接通过gem 工具实现这一点,而不需要 Bundler。但是,当我运行时:
$ export MYKEY=key
$ gem fetch --clear-sources -s "https://private.repository.com/" mygem
我明白了:
ERROR: Could not find a valid gem 'mygem' (>= 0), here is why:
Unable to download data from https://private.repository.com/ - bad response Unauthorized 401 (https://private.repository.com/other/stuff)
为什么以及如何不同?如何通过gem 工具获取 gem?
【问题讨论】:
-
您是否设置了
~/.gemrc与您的私人仓库的凭据? Bundler 使用其配置机制来存储私有源凭据,这与gem使用的不同。 -
花了我一段时间才弄明白 :) 我已经添加了解决方案。