Skip to content

Bazel build with prost-build build.rs fails with "No such file or directory" #454

Closed
@ttiurani

Description

@ttiurani

I created a demo repository:

https://github.com/ttiurani/bazel-prost-build-bug

to showcase an issue where the standard prost-build example works fine with a cargo build but running the same with cargo raze'd Bazel repository with bazel build demo fails with:

ERROR: /private/var/tmp/_bazel_ttiurani/0c87cdffcf4741baaa498655bde07714/external/raze__demo_prost_build__0_0_1/BUILD.bazel:36:19: CargoBuildScriptRun external/raze__demo_prost_build__0_0_1/demo_prost_build_build_script.out_dir failed (Exit 1) cargo_build_script_runner failed: error executing command bazel-out/darwin-opt-exec-2B5CBBC6/bin/external/io_bazel_rules_rust/cargo/cargo_build_script_runner/cargo_build_script_runner ... (remaining 8 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', external/raze__demo_prost_build__0_0_1/cargo/build.rs:2:66
stack backtrace:
   0:        0x10cac9a6e - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h24bb64d98a7e25d6
   1:        0x10caeaf9c - core::fmt::write::h8fdc9cddb01cd8b2
   2:        0x10cac6bd9 - std::io::Write::write_fmt::hcc3030013983bab6
   3:        0x10cacbc35 - std::panicking::default_hook::{{closure}}::h95817712c5ff0736
   4:        0x10cacb972 - std::panicking::default_hook::h34e085f4e0b1062d
   5:        0x10cacc195 - std::panicking::rust_panic_with_hook::haf571858f996ac45
   6:        0x10cacbd62 - rust_begin_unwind
   7:        0x10caf37ef - core::panicking::panic_fmt::h11676ba6a846d9f4
   8:        0x10caf36f5 - core::option::expect_none_failed::h312e48bacb63d8ec
   9:        0x10ca81c1b - demo_prost_build_build_script_script_::main::h399dfdb84fd54273
  10:        0x10ca82986 - std::rt::lang_start::{{closure}}::h0a0a8f1aceef40a7
  11:        0x10cacc45f - std::rt::lang_start_internal::hcd84a36052901671
  12:        0x10ca81c69 - main
Error: "Build script process failed with exit code 101"

Where the build.rs is:

fn main() {
    prost_build::compile_protos(&["src/items.proto"], &["src/"]).unwrap();
}

The error message is quite non-descriptive so was unable to trace this further myself. Note that I'd very much like to use the bundled protoc binary and not an external one to make my build easily repeatable in CI environments.

Any ideas what might be wrong? I'm using the latest rules_rust from this morning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions