grpc-rs icon indicating copy to clipboard operation
grpc-rs copied to clipboard

Failed generate rust code with proto-grpcio

Open LyunKi opened this issue 6 years ago • 14 comments
trafficstars

sorry,my English isnt well,so I try to descript the problem I had Describe the bug After read the Readme, I can generate throuth the first way Manual Generation with command protoc --rust_out=. --grpc_out=. --plugin=protoc-gen-grpc=which grpc_rust_plugin example.proto. bug when I try to generate proto file by protoc-grpcio.cargo build fail failed to execute command: Permission denied (os error 13). and the trace show that it panic at

        if self.always_configure || !build.join("CMakeCache.txt").exists() {
            run(cmd.env("CMAKE_PREFIX_PATH", cmake_prefix_path), "cmake");
        } else {
            println!("CMake project was already configured. Skipping configuration step.");
        }
fn run(cmd: &mut Command, program: &str) {
    println!("running: {:?}", cmd);
    let status = match cmd.status() {
        Ok(status) => status,
        Err(ref e) if e.kind() == ErrorKind::NotFound => {
            fail(&format!("failed to execute command: {}\nis `{}` not installed?",
                          e, program));
        }
        Err(e) => fail(&format!("failed to execute command: {}", e)),
    };
    if !status.success() {
        fail(&format!("command did not execute successfully, got: {}", status));
    }
}

To Reproduce Steps to reproduce the behavior:

  1. clone the project protoc-grpcio
  2. run the command cargo run --manifest-path example/Cargo.toml --bin server

Expected behavior build fail and panic thread 'main' panicked at ' failed to execute command: Permission denied (os error 13)

System information

  • Ubuntu18.04
  • libprotoc version 3.7.0
  • cmake version 3.12.2
  • rust 1.35-nightly
  • go 1.11.5
  • GNU ld (GNU Binutils) 2.32
  • gcc 7.3.0

Additional context

  • . - @mtp401

LyunKi avatar Mar 29 '19 13:03 LyunKi

Could you please provide your example.proto file?

ice1000 avatar Mar 29 '19 23:03 ice1000

Could you please provide your example.proto file?

syntax = "proto3";

package example;

service Diner {
  rpc Eat(Order) returns (Check) {}
}

enum Item {
  SPAM = 0;
  EGGS = 1;
  HAM = 2;
}

message Order {
  repeated Item items = 1;
}

message Check {
  double total = 1;
}

It is the example proto of the project proto-grpcio . ice juju...

LyunKi avatar Mar 29 '19 23:03 LyunKi

事实上让我很困惑的是,一开始用的是命令行,是能够生成对应的文件的.后来下了protoc-grpcio后,他的demo无法运行-. - .后面还试了试grpc-rust.也是可以自动生成相关文件的. 下面这是完整的报错信息

running: "/home/lynss/softwares/envs/cmake" "/home/lynss/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/grpcio-sys-0.4.2/grpc" "-DgRPC_INSTALL=false" "-DgRPC_BUILD_CSHARP_EXT=false" "-DgRPC_BUILD_CODEGEN=false" "-DCMAKE_INSTALL_PREFIX=/home/lynss/projects/rust/protoc-grpcio/example/target/debug/build/grpcio-sys-47cecebc29b1342c/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_BUILD_TYPE=Debug"

build script failed, must exit now', /home/lynss/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/cmake-0.1.35/src/lib.rs:778:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
   5: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:381
   6: std::panicking::begin_panic_fmt
             at src/libstd/panicking.rs:336
   7: cmake::fail
             at /home/lynss/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/cmake-0.1.35/src/lib.rs:778
   8: cmake::run
             at /home/lynss/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/cmake-0.1.35/src/lib.rs:756
   9: cmake::Config::build
             at /home/lynss/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/cmake-0.1.35/src/lib.rs:611
  10: build_script_build::build_grpc
             at ./build.rs:98
  11: build_script_build::main
             at ./build.rs:187
  12: std::rt::lang_start::{{closure}}
             at /rustc/33ef0bad21d6bb646c7c3ab0dbf381ca96c324bf/src/libstd/rt.rs:64
  13: std::panicking::try::do_call
             at src/libstd/rt.rs:49
             at src/libstd/panicking.rs:293
  14: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:87
  15: std::rt::lang_start_internal
             at src/libstd/panicking.rs:272
             at src/libstd/panic.rs:388
             at src/libstd/rt.rs:48
  16: std::rt::lang_start
             at /rustc/33ef0bad21d6bb646c7c3ab0dbf381ca96c324bf/src/libstd/rt.rs:64
  17: main
  18: __libc_start_main
  19: _start

LyunKi avatar Mar 30 '19 00:03 LyunKi

I cannot reproduce the error under this environment:

  • Ubuntu 18.04
  • GNU ld (GNU Binutils for Ubuntu) 2.30
  • gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
  • libprotoc 3.1.0 (yes, I guess this is the cause, could you please try downgrading your protoc version?)
  • cmake version 3.10.2

ice1000 avatar Mar 30 '19 23:03 ice1000

When I run the example I get:

~/git-repos/protoc-grpcio|master λ> cargo run --manifest-path example/Cargo.toml --bin server
   Compiling grpcio-sys v0.4.2
   Compiling example v0.0.1 (/home/QAQ/git-repos/protoc-grpcio/example)
   Compiling grpcio v0.4.3
    Finished dev [unoptimized + debuginfo] target(s) in 8.44s
     Running `example/target/debug/server`
listening on 127.0.0.1:43353
Press ENTER to exit...

ice1000 avatar Mar 30 '19 23:03 ice1000

When I run the example I get:

~/git-repos/protoc-grpcio|master λ> cargo run --manifest-path example/Cargo.toml --bin server
   Compiling grpcio-sys v0.4.2
   Compiling example v0.0.1 (/home/QAQ/git-repos/protoc-grpcio/example)
   Compiling grpcio v0.4.3
    Finished dev [unoptimized + debuginfo] target(s) in 8.44s
     Running `example/target/debug/server`
listening on 127.0.0.1:43353
Press ENTER to exit...

好的,我试试换个版本的proto=. =

LyunKi avatar Mar 31 '19 06:03 LyunKi

When I run the example I get:

~/git-repos/protoc-grpcio|master λ> cargo run --manifest-path example/Cargo.toml --bin server
   Compiling grpcio-sys v0.4.2
   Compiling example v0.0.1 (/home/QAQ/git-repos/protoc-grpcio/example)
   Compiling grpcio v0.4.3
    Finished dev [unoptimized + debuginfo] target(s) in 8.44s
     Running `example/target/debug/server`
listening on 127.0.0.1:43353
Press ENTER to exit...

LyunKi avatar Mar 31 '19 07:03 LyunKi

When I run the example I get:

~/git-repos/protoc-grpcio|master λ> cargo run --manifest-path example/Cargo.toml --bin server
   Compiling grpcio-sys v0.4.2
   Compiling example v0.0.1 (/home/QAQ/git-repos/protoc-grpcio/example)
   Compiling grpcio v0.4.3
    Finished dev [unoptimized + debuginfo] target(s) in 8.44s
     Running `example/target/debug/server`
listening on 127.0.0.1:43353
Press ENTER to exit...

I cannot reproduce the error under this environment:

  • Ubuntu 18.04
  • GNU ld (GNU Binutils for Ubuntu) 2.30
  • gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
  • libprotoc 3.1.0 (yes, I guess this is the cause, could you please try downgrading your protoc version?)
  • cmake version 3.10.2

it dosent work yet.. now libprotoc version is 3.1.0

LyunKi avatar Mar 31 '19 08:03 LyunKi

besides , the module build failed is ' failed to run custom build command for grpcio-sys v0.4.2 '.and when i google it , i found a problem likes mine ,and grpc-rs is mentioned. failed to run custom build command for `grpcio-sys v0.1.1

LyunKi avatar Mar 31 '19 11:03 LyunKi

The panicking code is actually:

https://github.com/pingcap/grpc-rs/blob/f1216de3605e14d47067f8e1a2a74878240b7339/grpc-sys/build.rs#L98

which is a cmake error.

ice1000 avatar Apr 01 '19 20:04 ice1000

@Lynss Could you please provide your full log of cargo clean && cargo build? And please do enable verbose output, thanks.

ice1000 avatar Apr 07 '19 03:04 ice1000

it seems my fault... cause when I had to try to use the tower-grpc,the same error happened with 'permission denied'. 2019-04-09 20-21-02屏幕截图 2019-04-09 20-21-09屏幕截图 2019-04-09 20-24-53屏幕截图 2019-04-09 20-25-04屏幕截图 2019-04-09 20-25-08屏幕截图

LyunKi avatar Apr 09 '19 12:04 LyunKi

This is a really weird environment. I'm quite curious about what on earth is causing you permission denied. Have you tried building it in another bash env? Like the Ubuntu builtin terminal, instead of CLion/IntelliJ's terminal?

ice1000 avatar Apr 09 '19 19:04 ice1000

Clion's teminal had been set into oh_my_zsh...

LyunKi avatar Apr 10 '19 11:04 LyunKi