Carthage更新错误:"GitHub API请求失败:凭据有误"

4
这是我的 Cartfile 文件:
# Kanna HTML parsing library
github "tid-kijyun/Kanna" ~> 1.0.0

# Realm database/ORM
github "realm/realm-cocoa"

当我运行carthage update时,出现以下情况:
$ carthage --version
Unrecognized command: '--version'. See `carthage help`.

$ carthage update --platform OSX
*** Fetching realm-cocoa
*** Fetching Kanna
*** Skipped downloading realm-cocoa.framework binary due to the error:
    "GitHub API request failed: Bad credentials"
*** Checking out realm-cocoa at "v0.98.3"
*** Skipped downloading Kanna.framework binary due to the error:
    "GitHub API request failed: Bad credentials"
*** Checking out Kanna at "1.0.5"
*** xcodebuild output can be found in /var/folders/p2/c_d5mx0s3gl45165btrpx1fm0000gn/T/carthage-xcodebuild.KVYEob.log
*** Building scheme "Kanna_OSX" in Kanna.xcworkspace
*** Building scheme "RealmSwift" in RealmExamples.xcworkspace
*** Building scheme "Realm" in RealmExamples.xcworkspace

看起来它确实在构建Kanna和Realm,但我收到了一个关于GitHub API凭据错误的错误。出了什么问题?


你使用的是哪个版本的Carthage?你可以通过运行carthage version来确定。 - jpsim
@jpsim执行carthage version命令,显示版本号为0.15 - Will Hains
1
我不是Carthage专家,但从错误信息来看,似乎你的GitHub API凭据无效。从阅读Carthage的源代码(https://github.com/Carthage/Carthage/blob/0.15/Source/CarthageKit/GitHub.swift#L378-L409)来看,它似乎使用`GITHUB_ACCESS_TOKEN`来验证GitHub API请求。你是否将此值设置为环境变量?如果是,它是否是有效的令牌?你最近在GitHub.com上撤销了这个令牌吗?如果你的令牌是有效的且未被撤销,我建议你向Carthage项目提交问题,因为这可能是一个bug。 - jpsim
@jpsim 感谢您的研究。我没有设置 GITHUB_ACCESS_TOKEN 环境变量。除非我错过了什么,否则我在 Carthage 的 README.md 中没有看到有关设置 GitHub API 凭据或环境变量的任何信息。你是说使用 Carthage 需要 GitHub API 凭据吗? - Will Hains
1
不需要 GitHub API 凭据来使用 Carthage!但是,如果设置了凭据,Carthage 将尝试从 GitHub 发布中获取您的框架二进制文件。请在 https://github.com/Carthage/Carthage/issues/new 上提交问题,熟悉 Carthage 的人将能够帮助您。 - jpsim
@jpsim 完成了。https://github.com/Carthage/Carthage/issues/1188 - Will Hains
2个回答

3

我在回应一个Carthage问题时获得了解决方案:

  1. 编辑~/.gitconfig并添加以下内容:

    [credential] helper = osxkeychain [credential "https://github.com"] username = willhains

    (将willhains替换为您的GitHub用户名。)

  2. 通过HTTPS克隆私有存储库。

  3. OSX会提示您输入GitHub密码。

  4. 运行carthage update


无法打开~/.gitconfig文件,权限被拒绝。 - coreDeviOS
@coreDeviOS 在打开该文件时,请使用sudo命令。 请记住,您需要使用某个文本编辑器打开该文件。例如,您可以使用内置的nano编辑器: sudo nano ~/.gitconfig - Artem M

2

如果你想跳过查找二进制文件,直接从源代码构建:

carthage update --no-use-binaries 

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接