bazelbuild / rules_rust

Rust rules for Bazel
https://bazelbuild.github.io/rules_rust/
Apache License 2.0
656 stars 419 forks source link

`CARGO_MANIFEST_DIR was not set` error when building `rust_prost_library` #2669

Closed nmoroze closed 3 months ago

nmoroze commented 4 months ago

I'm currently running into an error where building a rust_prost_library fails with the following error:

thread 'main' panicked at 'CARGO_MANIFEST_DIR was not set: NotPresent', external/rules_rust/cargo/cargo_build_script_runner/bin.rs:33:59

I've attached a minimal tarball to reproduce this issue. It sets up rules_rust and protobuf tooling per the documentation, and tries to build a simple proto library. I'm not sure if there's something wrong in my setup, or a bug in rules_rust - as far as I can tell, this env variable should be set by the rules_rust infrastructure.

$ tar -xzvf reproducer.tar.gz
$ bazel build :foo_lib
...
thread 'main' panicked at 'CARGO_MANIFEST_DIR was not set: NotPresent', external/rules_rust/cargo/cargo_build_script_runner/bin.rs:33:59
...

reproducer.tar.gz

nmoroze commented 3 months ago

Following up, it looks like the issue disappears if .bazelversion is updated to 7.1.0. I still think this may be a bug, given that rules_rust supports Bazel 6.3.0 at a minimum (unless there's some required setup difference between Bazel versions).

Also note that there's a typo in the reproducer, so it won't quite build cleanly... but the expected result is for it to fail with the error

foo.proto:6:13: "FooRequeset" is not defined.
illicitonion commented 3 months ago

I think this is a duplicate of #2665?

journaux commented 2 months ago

+1