protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Rust Protobuf crate does not compile in bazel without `--spawn-strategy=standalone`.

Open berendjan opened this issue 1 month ago • 0 comments

Redirected from discussion

The v4 version of protobuf does not compile with bazel unless its running with --spawn-strategy=standalone or --spawn-strategy=local. see repo

This be easily reproduced with the following:

MODULE.bazel

"""Rust-Temp"""

module(
    name = "rust-temp",
    version = "0.0.0",
)

bazel_dep(name = "rules_rust", version = "0.67.0")  # https://github.com/bazelbuild/rules_rust/releases

crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")

crate.spec(package = "protobuf", version = "4.32.0-release")
crate.from_specs()
use_repo(crate, "crates")

BUILD.bazel

load("@rules_rust//rust:defs.bzl", "rust_binary")

rust_binary(
    name = "test",
    srcs = glob(["**/*.rs"]),
    deps = [
        "@crates//:protobuf",
    ],
)

main.rs

pub fn main() {
    println!("hello world");
}

The error emitted:

ERROR: /home/berend/.cache/bazel/_bazel_berend/6b2aa4fe5e02f6a12410110ed2ccd580/external/rules_rust++crate+crates__protobuf-4.32.0-release/BUILD.bazel:27:13: Compiling Rust rlib protobuf v4.32.0-release (20 files) failed: (Exit 1): process_wrapper failed: error executing Rustc command (from target @@rules_rust++crate+crates__protobuf-4.32.0-release//:protobuf) bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_rust+/util/process_wrapper/process_wrapper --env-file ... (remaining 35 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error: couldn't read `external/rules_rust++crate+crates__protobuf-4.32.0-release/src/upb/[lib.rs](http://lib.rs/)`: No such file or directory (os error 2)
  --> external/rules_rust++crate+crates__protobuf-4.32.0-release/src/shared.rs:75:1
   |
75 | mod upb;
   | ^^^^^^^^

error: aborting due to 1 previous error

Target //:test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 69.621s, Critical Path: 40.24s
INFO: 223 processes: 17 action cache hit, 134 internal, 89 linux-sandbox.
ERROR: Build did NOT complete successfully

berendjan avatar Nov 03 '25 14:11 berendjan