Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo incompatible_runfiles_cargo_manifest_dir #2898

Open
UebelAndre opened this issue Sep 24, 2024 · 5 comments
Open

Cargo incompatible_runfiles_cargo_manifest_dir #2898

UebelAndre opened this issue Sep 24, 2024 · 5 comments

Comments

@UebelAndre
Copy link
Collaborator

UebelAndre commented Sep 24, 2024

This flag implements a work-around for bazelbuild/bazel#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 #2887 (comment)

@UebelAndre
Copy link
Collaborator Author

UebelAndre commented Sep 24, 2024

Implemented in #2891

@UebelAndre UebelAndre changed the title Cargo incompatible_explicit_cargo_manifest_dir Cargo incompatible_runfiles_cargo_manifest_dir Sep 24, 2024
@UebelAndre
Copy link
Collaborator Author

Flipped in #2948

@gferon
Copy link
Contributor

gferon commented Oct 29, 2024

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.

@UebelAndre
Copy link
Collaborator Author

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.

manifest_dir = "{}/{}/{}".format(runfiles_dir.path, workspace_name, ctx.label.package)

@gferon
Copy link
Contributor

gferon commented Oct 30, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants