Bazel无法正确播放

发布于 2025-01-31 18:52:38 字数 815 浏览 2 评论 0原文

我正在尝试使用bazel执行flutter命令。这是我的build.bazel文件:

genrule(
    name = "flutter_build",
    srcs = [
        "//:root_filegroup"
    ],
    outs = ["out.txt"],
    cmd = "flutter build ipa --export-method development"
)

命令flutter build ipa -export-method开发如果我直接在我的iterm中直接运行它,则可以很好地工作。 ,但是由于某种原因,bazel中的同一命令返回许可错误:

Flutter failed to open a file at "/Users/rlanhe/tools/flutter/flutter/bin/cache/lockfile".
Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.
Try running:
  sudo chown -R $(whoami) /Users/rlanhe/tools/flutter/flutter/bin/cache/lockfile

嗯,对我来说没有意义,因为该文件夹已经有正确的权限,我可以在外面运行该命令<代码> Bazel 。

I'm trying to execute a flutter command using bazel. This is my BUILD.bazel file:

genrule(
    name = "flutter_build",
    srcs = [
        "//:root_filegroup"
    ],
    outs = ["out.txt"],
    cmd = "flutter build ipa --export-method development"
)

The command flutter build ipa --export-method development works perfectly if I run it directly in my iterm, but for some reason the same command in bazel returns a permission error:

Flutter failed to open a file at "/Users/rlanhe/tools/flutter/flutter/bin/cache/lockfile".
Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.
Try running:
  sudo chown -R $(whoami) /Users/rlanhe/tools/flutter/flutter/bin/cache/lockfile

Well, doesn't make sense to me, since that folder already have correct permission and I'm able to run the command outside bazel.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

影子的影子 2025-02-07 18:52:38

整合颤音/飞镖和巴泽尔可能是大量工作。

这里有一个问题:
https://github.com/flutter/flutter/issues/19680

And it looks就像这里有一些飞镖规则:
https://github.com/cbracken/rules_dart

The immediate issue you're running into is that Bazel在沙箱中运行每个动作(即构建步骤),因此,除非声明了该动作的输入,否则它不会在沙箱中。 You can maybe get further by adding tags = ["no-sandbox"] to the genrule, (see

This is essentially running one build system inside another, and this isn't going get the caching and incrementality benefits of Bazel, because Bazel has no insight into what happens inside the genrule. Unless you have some higher-level plans to integrate this into a larger repository that uses Bazel, there isn't much benefit here compared to running flutter directly or in a shell script.

Integrating Flutter/Dart and Bazel is likely a large amount of work.

There's an issue here about it:
https://github.com/flutter/flutter/issues/19680

And it looks like there are some dart rules here:
https://github.com/cbracken/rules_dart

The immediate issue you're running into is that Bazel runs each action (i.e. build step) in a sandbox, so unless an input to the action is declared, it's not going to be in the sandbox. You can maybe get further by adding tags = ["no-sandbox"] to the genrule, (see https://bazel.build/reference/be/common-definitions#common.tags).

This is essentially running one build system inside another, and this isn't going get the caching and incrementality benefits of Bazel, because Bazel has no insight into what happens inside the genrule. Unless you have some higher-level plans to integrate this into a larger repository that uses Bazel, there isn't much benefit here compared to running flutter directly or in a shell script.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文