首页 > 解决方案 > carthage bootstrap 失败,因为并行 git 进程访问共享缓存 index.lock 文件

问题描述

我正在Jenkins 从站上从 Jenkins并行触发多个 iOS 构建。当构建触发以下命令时,我收到错误消息。

命令

carthage bootstrap --no-use-binaries --platform ios --use-ssh --cache-builds

输出

2020-01-29 21:34:58.471 carthage[85379:2625480] INFO: fetch-response is unable to open the file /Users/user/Library/Caches/carthage/fsCachedData/7A4CE621-0AC6-4FAF-B0CE-33FDD32A0113. Errno: 2
*** Checking out Alamofire at "4.8.2"
*** Checking out ios-client at "3.0.0"
*** Checking out stripe-ios at "v18.3.0"
*** Checking out swift-protobuf at "1.5.0"
A shell task (/usr/bin/env git checkout --quiet --force v18.3.0 (launched in /Users/user/Library/Caches/org.carthage.CarthageKit/dependencies/stripe-ios)) failed with exit code 128:
fatal: Unable to create '/Users/user/Library/Caches/org.carthage.CarthageKit/dependencies/stripe-ios/./index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.

make: *** [carthage-install] Error 1

如何解决这个问题?我猜这是因为多个进程试图访问共享的 Carthage 缓存。

标签: iosxcodegitjenkinscarthage

解决方案


您是否在 Carthage 存储库中发现了这个问题?似乎它描述了您遇到的问题:https ://github.com/Carthage/Carthage/issues/1187

问题是 Carthage 从未打算并行运行,因为如果多个 Carthage 作业以同一用户身份运行,它使用的锁可能会挂起。如果您将 CI 机器配置为拥有多个用户,其中每个用户运行一个 Carthage 作业,则不应出现此问题。如果您有一个用户在机器启动时自动登录,该用户启动多个构建代理,并且这些代理可以在他们的 Carthage 活动中重叠,那么构建可能会以您描述的方式失败。

Carthage 的一个分支声称已经解决了这个问题:https ://github.com/nsoperations/Carthage - 我还没有尝试过,但我想我会的。如果您在使用 Carthage 时遇到困难,并且希望您的 Mac CI 机器从断电中恢复到多个构建代理(例如 Buildkite)正在运行的状态,我认为这可能是唯一的答案。如果我知道一种使多个用户自动登录的可靠方法,每个用户在登录时启动代理进程,那将使得继续使用 Carthage 的主分支成为可能。


推荐阅读