rules_rust icon indicating copy to clipboard operation
rules_rust copied to clipboard

Cargo `incompatible_runfiles_cargo_manifest_dir`

Open UebelAndre opened this issue 1 year ago • 2 comments

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

UebelAndre avatar Sep 24 '24 15:09 UebelAndre

Implemented in https://github.com/bazelbuild/rules_rust/pull/2891

UebelAndre avatar Sep 24 '24 15:09 UebelAndre

Flipped in https://github.com/bazelbuild/rules_rust/pull/2948

UebelAndre avatar Oct 18 '24 17:10 UebelAndre

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.

gferon avatar Oct 29 '24 17:10 gferon

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.

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

UebelAndre avatar Oct 29 '24 18:10 UebelAndre

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!

gferon avatar Oct 30 '24 07:10 gferon