Imagine you're running Bazel on a Mac, but you're making use of a remote execution service that provides workers for both Linux and macOS. You want to prefer the use of Linux workers over macOS, so your .bazelrc looks like this:
This is caused by the fact that @rules_rust//tools/rustfmt:rustfmt has data = ["//rust/toolchain:current_rustfmt_toolchain"]. The latter is only intended to be used as part of ctx.actions.run() (the 'exec' platform). In this case we require that a copy of rustfmt is used for the 'target' platform.
Imagine you're running Bazel on a Mac, but you're making use of a remote execution service that provides workers for both Linux and macOS. You want to prefer the use of Linux workers over macOS, so your .bazelrc looks like this:
Now if we invoke
@rules_rust//:rustfmt
, we see the following:This is caused by the fact that
@rules_rust//tools/rustfmt:rustfmt
hasdata = ["//rust/toolchain:current_rustfmt_toolchain"]
. The latter is only intended to be used as part ofctx.actions.run()
(the 'exec' platform). In this case we require that a copy of rustfmt is used for the 'target' platform.For similar mishaps, see https://github.com/bazelbuild/bazel/issues/19645 and https://github.com/bazel-contrib/rules_oci/pull/590.