【问题标题】:Carthage update error: "GitHub API request failed: Bad credentials"Carthage 更新错误:“GitHub API 请求失败:凭据错误”
【发布时间】:2016-03-04 07:41:48
【问题描述】:

这是我的购物车文件:

# 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 version 来确定这一点。
  • @jpsim carthage version0.15
  • 我不是 Carthage 专家,但从错误消息来看,您的 GitHub API 凭据似乎无效。通过阅读 Carthage 的源代码 (github.com/Carthage/Carthage/blob/0.15/Source/CarthageKit/…),它似乎正在使用 GITHUB_ACCESS_TOKEN 来验证 GitHub API 请求。您是否将此值设置为环境变量?如果是这样,它是一个有效的令牌吗?您最近是否在 GitHub.com 上撤销了此令牌?如果您的令牌有效且未被撤销,我建议您向 Carthage 项目提交问题,因为这可能是一个错误。
  • @jpsim 感谢您的研究。我没有设置GITHUB_ACCESS_TOKEN env var。除非我错过了它,否则我在 Carthage 的 README.md 中看不到任何关于设置 GitHub API 凭据或环境变量的内容。你是说使用 Carthage 需要 GitHub API 凭据??
  • 不,使用 Carthage 不需要 GitHub API 凭据!但如果设置,Carthage 将尝试使用它从 GitHub 版本中获取框架的二进制文件。请在github.com/Carthage/Carthage/issues/new 上提出问题,更熟悉 Carthage 的人将能够为您提供帮助。

标签: swift realm carthage


【解决方案1】:

我得到了回复我提出的Carthage issue 的解决方案:

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

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

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

  2. 通过 HTTPS 克隆私有仓库。

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

  4. 运行carthage update

【讨论】:

  • 无法打开 ~/.gitconfig ,权限被拒绝。
  • @coreDeviOS 打开该文件时使用sudo 命令。请记住,您需要使用一些文本编辑器打开文件。例如,您可以使用内置的 nano 编辑器:sudo nano ~/.gitconfig
【解决方案2】:

如果您想跳过查找二进制文件而只从源代码构建:

carthage update --no-use-binaries 

【讨论】:

    猜你喜欢
    • 2014-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-27
    • 1970-01-01
    • 1970-01-01
    • 2014-05-08
    • 1970-01-01
    相关资源
    最近更新 更多