cocopods与Bazel安装颤抖时的错误

发布于 2025-02-04 06:19:07 字数 1592 浏览 0 评论 0原文

我正在尝试使用bazel和flutter构建ipa文件,然后我有以下构建文件:

genrule(
    name = "flutter_build_ios",
    srcs = glob(["ios/**","lib/**","assets/**", "pubspec.yaml"]),
    outs = ["mobile.ipa"],
    cmd_bash = "flutter build ipa --export-options-plist ios/Runner/ExportOptions.plist --obfuscate --split-debug-info=build/app/outputs/symbols && cp build/ios/ipa/mobile.ipa $@ && cp build/app/outputs/symbols $(@D)",
    tags = ["local"]
)

当我尝试执行bazel命令:@bazel build //:flutter_build_ios- verbose_failures我有错误:

(Could not create '/var/root/.cocoapods/repos', the CocoaPods repo cache directory.
Errno::EACCES: Permission denied @ dir_s_mkdir - /var/root/.cocoapods)
You can try adding it manually in `/var/root/.cocoapods/repos` or via `pod repo add`.

我不知道为什么巴泽尔试图使用/var/root而不是〜/library/caches/caches/cocoapods/。我尝试在终端中执行相同的命令,而无需Bazel:flutter build ipa -export-options-plist ios/runner/exportoptions.plist-obfuscate-obfuscate -split-debug-info = build/app/app/outputs/outputs/outputs/outputs/outputs/outputs/outputs/outputs/outputs/outputs/outputs/utputs/符号,一切正常。

我想我错过了巴泽尔如何在引擎盖下工作的东西。

解决方案: 执行CMD命令( https:https: //bazel.build/reference/be/general#genrule-environment ),并且由于cocopods依靠某些环境变量,我需要设置以下export cp_home_dir = /tmp/cocoapods-repo执行任何内容。

I'm trying to build an ipa file using bazel and flutter, then I have the following BUILD file:

genrule(
    name = "flutter_build_ios",
    srcs = glob(["ios/**","lib/**","assets/**", "pubspec.yaml"]),
    outs = ["mobile.ipa"],
    cmd_bash = "flutter build ipa --export-options-plist ios/Runner/ExportOptions.plist --obfuscate --split-debug-info=build/app/outputs/symbols && cp build/ios/ipa/mobile.ipa $@ && cp build/app/outputs/symbols $(@D)",
    tags = ["local"]
)

When I try to execute the bazel command: @bazel build //:flutter_build_ios --verbose_failures I got error:

(Could not create '/var/root/.cocoapods/repos', the CocoaPods repo cache directory.
Errno::EACCES: Permission denied @ dir_s_mkdir - /var/root/.cocoapods)
You can try adding it manually in `/var/root/.cocoapods/repos` or via `pod repo add`.

I don't know why bazel is trying to use /var/root instead of ~/Library/Caches/CocoaPods/. I tried execute the same command in my terminal, without bazel: flutter build ipa --export-options-plist ios/Runner/ExportOptions.plist --obfuscate --split-debug-info=build/app/outputs/symbols and everything works fine.

I think I'm missing something about how bazel works under the hood.

Solution:
Genrule keeps only basic environment variables when executing cmd commands (https://bazel.build/reference/be/general#genrule-environment), and since cocopods rely on some environment variables, I have needed to set the following export CP_HOME_DIR=/tmp/cocoapods-repo before execute anything.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文