Bazel无法正确播放
我正在尝试使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
整合颤音/飞镖和巴泽尔可能是大量工作。
这里有一个问题:
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, (seeThis 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.