未经授权的 401 来自`gem`

问题描述 投票:0回答:1
$ gem install bundler:2.2.21
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    bad response Unauthorized 401 (https://bart_simpson:[email protected]/private_org/api/v1/dependencies?gems=bundler)

$ gem update --system
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    bad response Unauthorized 401 (https://bart_simpson:[email protected]/private_org/specs.4.8.gz)

我在两个地方设置了一个良好的个人令牌(良好 = 完全权限,且未过期):

$ cat ~/.bundle/config 
---
BUNDLE_RUBYGEMS__PKG__GITHUB__COM: "bart_simpson:ghp_nJabIP9JjPe7KOwgDrkiJextJggm114MZh7f"
BUNDLE_HTTPS://RUBYGEMS__PKG__GITHUB__COM/PRIVATE_ORG/: "bart_simpson:ghp_nJabIP9JjPe7KOwgDrkiJextJggm114MZh7f"

$ cat ~/.gem/credentials
---
:github: Bearer ghp_nJabIP9JjPe7KOwgDrkiJextJggm114MZh7f
github rubygems bundler
1个回答
2
投票

啊!生成新的个人令牌并将其保存在问题中提到的两个位置后,我忘记了第三个位置(它起到了作用)......

$ cat ~/.gemrc 
---
:backtrace: false
:bulk_threshold: 1000
:sources:
- https://rubygems.org/
- https://bart_simpson:[email protected]/private_org/
:update_sources: true
:verbose: true

文档:https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-rubygems-registry#authenticating-with-a-personal-access-代币

© www.soinside.com 2019 - 2024. All rights reserved.