rules_rust
rules_rust copied to clipboard
Cargo `incompatible_runfiles_cargo_manifest_dir`
This flag implements a work-around for https://github.com/bazelbuild/bazel/issues/15486 that enables cargo_build_script to explicitly create a directory to use as a crate's CARGO_MANIFEST_DIR that can be passed to dependent actions.
--@rules_rust//cargo/incompatible_runfiles_cargo_manifest_dir
The intent of this flag is to eliminate non-hermetic behavior in interactions with CARGO_MANIFEST_DIR when building without a sandbox. For details see https://github.com/bazelbuild/rules_rust/pull/2887#issue-2535499922
Implemented in https://github.com/bazelbuild/rules_rust/pull/2891
Flipped in https://github.com/bazelbuild/rules_rust/pull/2948
I didn't get the opportunity to dive deeper, but this broke bringing any data accessible by a build script in Bazel for us. When using the data attribute of a cargo_build_script named bs, the files are symlinked in a directory called bs-.runfiles (instead of bs-cargo.runfiles) which is not where the build script is executed. I can provide more info if necessary.
I didn't get the opportunity to dive deeper, but this broke bringing any
dataaccessible by a build script in Bazel for us. When using thedataattribute of acargo_build_scriptnamedbs, the files are symlinked in a directory calledbs-.runfiles(instead ofbs-cargo.runfiles) which is not where the build script is executed. I can provide more info if necessary.
More details would be great! The build script should be running in CARGO_MANIFEST_DIR which should be set to a path within the .cargo_runfiles directory.
https://github.com/bazelbuild/rules_rust/blob/a6426e06d0351fc7ff80f6cfaa39b274dbb95289/cargo/private/cargo_build_script.bzl#L336
I managed to make it work by adding one extra include path to protoc. What threw me off is that we already had an extra relative path, namely ../../external/protobuf~/src and I now have to add ../../../protobuf~/src. Not sure why external is gone, but I suppose that's OK. Apologies for the false alarm!