Skip to content

After updating to v0.7 with prost-types v0.10 "google.protobuf.rs" is not available #964

@g0hl1n

Description

@g0hl1n

Bug Report

Version

$ cargo tree | grep -e tonic -e prost
├── prost v0.10.0
│   └── prost-derive v0.10.0 (proc-macro)
├── prost-types v0.10.0
│   └── prost v0.10.0 (*)
└── tonic v0.7.1
    ├── prost v0.10.0 (*)
    ├── prost-derive v0.10.0 (proc-macro) (*)
├── tonic-build v0.7.0
│   ├── prost-build v0.10.0
│   │   ├── prost v0.10.0
│   │   │   └── prost-derive v0.10.0 (proc-macro) (*)
│   │   ├── prost-types v0.10.0
│   │   │   └── prost v0.10.0 (*)

Platform

Fedora release 35 (Thirty Five)

Linux 5.16.16-200.fc35.x86_64

Crates

  • tonic-build

Description

After updating to tonic{,-build} v0.7 and prost{,-types} v0.10 cargo build fails with

error: couldn't read /.../target/debug/build/.../out/google.protobuf.rs: No such file or directory (os error 2)
 --> /.../target/debug/build/.../out/grpc_api_mod.rs:3:9
  |
3 |         include!("google.protobuf.rs");
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `...` due to previous error

build.rs calls:

fn gen_grpc_srv(include_file: &str, protos: Vec<String>) -> Result<(), Box<dyn std::error::Error>> {
    let proto_path = env::var("OUT_DIR").unwrap() + "/proto";
    tonic_build::configure()
        .build_server(true)
        .include_file(&include_file)
        .compile(&protos, &[proto_path])?;
    Ok(())
}

The google.protobuf.rs isn't available in the target directory:

$ find target -name google.protobuf.rs | wc -l
0

Using tonic-build's .compile_well_known_types(true) instead of prost-types works.

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