tonic: tonic-examples build crashes: "No such file or directory"
Bug Report
Building the examples in tonic-examples
in this repository crashes.
Version
I just checked out this repository, so it’s just master
of tonic
.
$ git rev-parse HEAD
af5754bd437ffbb5c7a9fbe36af14cd182d48c53
Platform
$ uname -a
Linux think5 4.19.80 #1-NixOS SMP Thu Oct 17 20:45:44 UTC 2019 x86_64 GNU/Linux
$ rustc --version
rustc 1.39.0-beta.7 (23f8f652b 2019-10-26)
$ cargo --version
cargo 1.39.0-beta (1c6ec66d5 2019-09-30)
Description
Following tonic-examples/README.md, I tried to run helloworld-client
.
This resulted in the following build error:
$ cargo run --bin helloworld-client
[...]
Compiling tonic-examples v0.1.0 (/home/leo/Code/other/tonic/tonic-examples)
error: failed to run custom build command for `tonic-examples v0.1.0 (/home/leo/Code/other/tonic/tonic-examples)`
Caused by:
process didn't exit successfully: `/home/leo/Code/other/tonic/target/debug/build/tonic-examples-c5600591329ec7f8/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/libcore/result.rs:1165:5
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/libunwind.rs:88
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:76
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:60
4: core::fmt::write
at src/libcore/fmt/mod.rs:1030
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1412
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:64
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:49
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:196
9: std::panicking::default_hook
at src/libstd/panicking.rs:210
10: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:477
11: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:380
12: rust_begin_unwind
at src/libstd/panicking.rs:307
13: core::panicking::panic_fmt
at src/libcore/panicking.rs:85
14: core::result::unwrap_failed
at src/libcore/result.rs:1165
15: core::result::Result<T,E>::unwrap
at /rustc/23f8f652bcea053b70c0030008941f5f8476b5a0/src/libcore/result.rs:933
16: build_script_build::main
at tonic-examples/build.rs:2
17: std::rt::lang_start::{{closure}}
at /rustc/23f8f652bcea053b70c0030008941f5f8476b5a0/src/libstd/rt.rs:64
18: std::rt::lang_start_internal::{{closure}}
at src/libstd/rt.rs:49
19: std::panicking::try::do_call
at src/libstd/panicking.rs:292
20: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:80
21: std::panicking::try
at src/libstd/panicking.rs:271
22: std::panic::catch_unwind
at src/libstd/panic.rs:394
23: std::rt::lang_start_internal
at src/libstd/rt.rs:48
24: std::rt::lang_start
at /rustc/23f8f652bcea053b70c0030008941f5f8476b5a0/src/libstd/rt.rs:64
25: main
26: __libc_start_main
27: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...
error: build failed
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 32 (16 by maintainers)
OMG that worked @cpcloud! 🤦♂️ sorry about this, and thanks to everyone for the help!
Side note - I get that Rust’s
NotFound
is designed not to allocate and therefore can’t contain the name of the thing that it failed to find. But it would have been so useful in this case for it to say “No such file or directory: protoc” instead of “No such file or directory” …Anyway, thanks! I’m not sure if you anticipate a lot of Nix users using tonic. Here’s the
shell.nix
that worked for me in case you’d like to refer to it somewhere:@b333z thanks for the pointers! Coming back to tonic after a while, I encountered the same issue again. For the record, here is how to run the helloworld example in NixOS:
this shell.nix would provide a good access to Tonic development on NixOS with nix-shell
In case of use, I landed here after this https://github.com/danburkert/prost/issues/182 were https://github.com/nagisa strace’d out the other bit of the puzzle.
So looks like prost finds its own bundled protoc which will have a bad interpreter on a nixos system (being a non-patchelf’d foreign binary) and am guessing the
NotFound
comes up from std at the point of executing the bundled protoc referring more to NotFounding the interpreter rather than the binary.It should, right? That’s my understanding too. However, the
prost
0.5.0 error message(https://github.com/danburkert/prost/blob/v0.5.0/prost-build/build.rs#L98-L99) is nowhere to be seen in my logs. Having it there would have made it immediately obvious what the problem was. So somewhere that error message must be swallowed, right?
@curiousleo Can you try adding
protobuf
to your overlay’sbuildInputs
and then settingPROTOC = "${protobuf}/bin/protoc";
?