bazelbuild / bazelbuild/rules_rust
error inheriting from workspace root manifest in CargoBuildScriptRun when using crates_universe
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
We're using crates_universe to pull in this dependency https://github.com/bitdriftlabs/shared-core/blob/b29ed8fc031feb5e863fd0d39c626133a3804996/bd-bonjson/Cargo.toml which uses a build.rs to generate some FFI bindings.
On the consuming end when we define a dependency on this crate in our Cargo.toml using the crates_universe cargo config we see the following error
```
thread 'main' panicked at external/rules_rust++crate+crates__bd-bonjson-1.0.0/build.rs:21:6:
called `Result::unwrap()` on an `Err` value: CargoMetadata("./Cargo.toml", Metadata(Output { status: ExitStatus(unix_wait_status(25856)), stdout: "", stderr: "error: failed to parse manifest at `/private/var/tmp/_bazel_kstenerud/01c9e6fe2981713edb8cb13e552dd535/rules_xcodeproj.noindex/build_output_base/execroot/_main/bazel-out/ios_arm64-dbg-ios-arm64-min15.0-applebin_ios-ST-9f7cf20e07d1/bin/external/rules_rust++crate+crates__bd-bonjson-1.0.0/_bs.cargo_runfiles/rules_rust++crate+crates__bd-bonjson-1.0.0/Cargo.toml`\n\nCaused by:\n error inheriting `tempfile` from workspace root manifest's `workspace.dependencies.tempfile`\n\nCaused by:\n `dependency.tempfile` was not found in `workspace.dependencies`\n" }))
stack backtrace:
0: 0x1004e752c - ::fmt::h2c3f7b4c4ce00f07
1: 0x1005034e8 - core::fmt::write::h1dbafa36e52e01c5
2: 0x1004e4fd8 - std::io::Write::write_fmt::he72d49f3084ee601
3: 0x1004e73e0 - std::sys::backtrace::BacktraceLock::print::h1fb87370474572ed
4: 0x1004e8898 - std::panicking::default_hook::{{closure}}::h195a9b2c829547eb
5: 0x1004e86e8 - std::panicking::default_hook::h18c3aa3e3a3584d5
6: 0x1004e9378 - std::panicking::rust_panic_with_hook::h02a9fa3cad928562
7: 0x1004e8fa4 - std::panicking::begin_panic_handler::{{closure}}::hd1cc56578f819958
8: 0x1004e79f0 - std::sys::backtrace::__rust_end_short_backtrace::h52c1e479035e4bc4
9: 0x1004e8c4c - __rustc[4794b31dd7191200]::rust_begin_unwind
10: 0x100518924 - core::panicking::panic_fmt::heec96bfc27e6c546
11: 0x100518c14 - core::result::unwrap_failed::hfab4c59284c125d5
12: 0x10028c100 - build_script_build::main::h388ed677df26d923
13: 0x10029e180 - std::sys::backtrace::__rust_begin_short_backtrace::h60d723c466e3d118
14: 0x10028c59c - std::rt::lang_start::{{closure}}::h190c46af354a7c37
15: 0x1004e0c8c - std::rt::lang_start_internal::ha7d36e169a6a9a91
16: 0x10028c3f8 - _main
ERROR: /private/var/tmp/_bazel_kstenerud/01c9e6fe2981713edb8cb13e552dd535/rules_xcodeproj.noindex/build_output_base/external/rules_rust++crate+crates__bd-bonjson-1.0.0/BUILD.bazel:27:13 Compiling Rust rlib bd_bonjson v1.0.0 (287 files) failed: (Exit 1): runner failed: error executing CargoBuildScriptRun command (from target @@rules_rust++crate+crates__bd-bonjson-1.0.0//:_bs)
```
This works fine when building with `cargo`, so there seems to be something off about how rules_rust handles this case.
A few things to note:
- This happens in CargoBuildScriptRun, so we suspect this is related to how build.rs is done. We don't run into similar issues with other crates that use workspace dependencies
- We can work around this by having the failing crate not use workspace dependencies
- The Cargo.Bazel.lock file is generated with the correct versions, so this doesn't seem to be a version resolution issue but an issue invoking CargoManifest during the actual build
- We're using rules_rust 0.61.0 and didn't see anything that would have fixed this in the later releases
Contributor guide
Assessment
This issue has not been assessed yet.