Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tonic-build fails when service in/out objects are extern_path'd #260

Closed
cthulhua opened this issue Feb 6, 2020 · 0 comments
Closed

tonic-build fails when service in/out objects are extern_path'd #260

cthulhua opened this issue Feb 6, 2020 · 0 comments

Comments

@cthulhua
Copy link
Contributor

cthulhua commented Feb 6, 2020

Bug Report

Version

tonic 0.1.1

Platform

Darwin Dannys-Work-MacBook-Pro.local 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64

Crates

tonic-build

Description

The replace_wellknown function in tonic-build/src/lib.rs fails when any objects referred to in service method definitions have been replaced (via tonic/prost's extern_path functionality). These paths are absolute paths and should not be replace with a relative path rooted at super.

This failure results in a build failure (panic during build.rs execution):

   Compiling my_application v0.1.0 (/Users/danny/tonic_extern_path/my_application)
error: failed to run custom build command for `my_application v0.1.0 (/Users/danny/tonic_extern_path/my_application)`

Caused by:
  process didn't exit successfully: `/Users/danny/tonic_extern_path/target/debug/build/my_application-807cb5f2cea6c0e3/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("expected identifier")', /Users/danny/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/tonic-build-0.1.1/src/lib.rs:332:9
stack backtrace:
   0:        0x10b6f6135 - backtrace::backtrace::libunwind::trace::h2645f0921d177f94
                               at /Users/runner/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1:        0x10b6f6135 - backtrace::backtrace::trace_unsynchronized::h2d634d751cc39c09
                               at /Users/runner/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2:        0x10b6f6135 - std::sys_common::backtrace::_print_fmt::hbf6c15b03ac1eab6
                               at src/libstd/sys_common/backtrace.rs:77
   3:        0x10b6f6135 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0e1e1d13ef39c2d8
                               at src/libstd/sys_common/backtrace.rs:59
   4:        0x10b712e6d - core::fmt::write::h1fc31e3d3e8cc0fb
                               at src/libcore/fmt/mod.rs:1052
   5:        0x10b6f31db - std::io::Write::write_fmt::hfa2e20b6b4a124b0
                               at src/libstd/io/mod.rs:1426
   6:        0x10b6f855a - std::sys_common::backtrace::_print::h589a150dbcdc1aa6
                               at src/libstd/sys_common/backtrace.rs:62
   7:        0x10b6f855a - std::sys_common::backtrace::print::h0a4ab12a7b4cb43a
                               at src/libstd/sys_common/backtrace.rs:49
   8:        0x10b6f855a - std::panicking::default_hook::{{closure}}::h3e9aecc37d191470
                               at src/libstd/panicking.rs:204
   9:        0x10b6f825a - std::panicking::default_hook::h80723c33c50f1398
                               at src/libstd/panicking.rs:224
  10:        0x10b6f8c9a - std::panicking::rust_panic_with_hook::h6b9654fdaf8aa8f2
                               at src/libstd/panicking.rs:476
  11:        0x10b6f8752 - rust_begin_unwind
                               at src/libstd/panicking.rs:380
  12:        0x10b7122bf - core::panicking::panic_fmt::h3216996c707890c3
                               at src/libcore/panicking.rs:85
  13:        0x10b712105 - core::option::expect_none_failed::h7164670b9c7e7202
                               at src/libcore/option.rs:1199
  14:        0x10b468fb4 - core::result::Result<T,E>::unwrap::h742815421e739a87
                               at /rustc/698fcd38fa9548e64a2092ff48c9d15ceb57d40c/src/libcore/result.rs:963
  15:        0x10b463946 - tonic_build::replace_wellknown::h0e195b786cbcb49f
                               at /Users/danny/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/tonic-build-0.1.1/src/lib.rs:332
  16:        0x10b4542c2 - tonic_build::client::generate_unary::h94345f34402983e9
                               at /Users/danny/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/tonic-build-0.1.1/src/client.rs:104
  17:        0x10b453e9c - tonic_build::client::generate_methods::h8537e877aab43f5f
                               at /Users/danny/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/tonic-build-0.1.1/src/client.rs:90
  18:        0x10b44e1e5 - tonic_build::client::generate::h02f17dc0bdb8042b
                               at /Users/danny/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/tonic-build-0.1.1/src/client.rs:9
  19:        0x10b46292f - <tonic_build::ServiceGenerator as prost_build::ServiceGenerator>::generate::hc92a32b4748ce54b
                               at /Users/danny/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/tonic-build-0.1.1/src/lib.rs:259
  20:        0x10b5ebac2 - prost_build::code_generator::CodeGenerator::push_service::{{closure}}::h52d5b08105d0fe2e
                               at /Users/danny/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/prost-build-0.6.1/src/code_generator.rs:676
  21:        0x10b62e9c4 - core::option::Option<T>::map::h68a992540e3f113b
                               at /rustc/698fcd38fa9548e64a2092ff48c9d15ceb57d40c/src/libcore/option.rs:450
  22:        0x10b5eaf6f - prost_build::code_generator::CodeGenerator::push_service::hb7ab3e997bce8594
                               at /Users/danny/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/prost-build-0.6.1/src/code_generator.rs:673
  23:        0x10b5e238f - prost_build::code_generator::CodeGenerator::generate::hf6d95ada164997aa
                               at /Users/danny/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/prost-build-0.6.1/src/code_generator.rs:103
  24:        0x10b63ae0f - prost_build::Config::generate::hb4f2ccd547f80360
                               at /Users/danny/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/prost-build-0.6.1/src/lib.rs:593
  25:        0x10b3e19df - prost_build::Config::compile_protos::h970129da4bfd3b2d
                               at /Users/danny/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/prost-build-0.6.1/src/lib.rs:552
  26:        0x10b3d9b43 - tonic_build::Builder::compile::h47d23e4abc40987d
                               at /Users/danny/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/tonic-build-0.1.1/src/lib.rs:167
  27:        0x10b421a32 - build_script_build::main::h7748d180a3d5dab2
                               at my_application/build.rs:2
  28:        0x10b403d46 - std::rt::lang_start::{{closure}}::h851e48dc34dc34e1
                               at /rustc/698fcd38fa9548e64a2092ff48c9d15ceb57d40c/src/libstd/rt.rs:67
  29:        0x10b6f8678 - std::rt::lang_start_internal::{{closure}}::hafd3c32b6306bd09
                               at src/libstd/rt.rs:52
  30:        0x10b6f8678 - std::panicking::try::do_call::h3d3fe791c338e3a4
                               at src/libstd/panicking.rs:305
  31:        0x10b6ff43b - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:86
  32:        0x10b6f903e - std::panicking::try::ha0910ebc7dfbfd90
                               at src/libstd/panicking.rs:281
  33:        0x10b6f903e - std::panic::catch_unwind::h5badc5d02ddc3558
                               at src/libstd/panic.rs:394
  34:        0x10b6f903e - std::rt::lang_start_internal::he9cd64fc2d39fad3
                               at src/libstd/rt.rs:51
  35:        0x10b403d22 - std::rt::lang_start::h645d221085e6c85b
                               at /rustc/698fcd38fa9548e64a2092ff48c9d15ceb57d40c/src/libstd/rt.rs:67
  36:        0x10b421b72 - build_script_build::main::h7748d180a3d5dab2

I've put my minimal repro at https://github.com/cthulhua/tonic_extern_path.

Note that in the Cargo.toml for the my_application I've added commented out references to https://github.com/cthulhua/tonic/tree/extern_path wherein I've fixed the issue by simply excluding absolute paths from being made relative

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants