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

Compiler assertion failed due to possible mismatch in protobuf version #6480

Closed
niketagrawal opened this issue Aug 6, 2019 · 1 comment
Closed

Comments

@niketagrawal
Copy link

What version of protobuf and what language are you using?
protoc --version: libprotoc 3.9.0
Language: Golang, version: go1.12.7 linux/amd64
What operating system (Linux, Windows, ...) and version?
Linux: Ubuntu 18.04.2 LTS (Bionic Beaver), 4.18.0-25-generic
What runtime / compiler are you using (e.g., python version or gcc version)
gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
What did you do?
Steps to reproduce the behavior:
I followed the instructions given at https://grpc.io/docs/quickstart/go/
Directly quoting them here step by step.

  1. Install go version 1.6 or higher. The version installed in my PC is go1.12.7 linux/amd64
  2. Install GRPC using the command go get -u google.golang.org/grpc
  3. Install protoc compiler using the pre-compiled binaries from the link. Chose protoc-3.9.0-linux-x86-arch_64.zip package, extracted it and added the binary's path to PATH variable.
  4. install the protoc plugin for Go using the command go get -u github.com/golang/protobuf/protoc-gen-go The compiler plugin, protoc-gen-go, will be installed in $GOBIN, defaulting to $GOPATH/bin. It must be in your $PATH for the protocol compiler, protoc, to find it.
  5. Check the proto version using the command protoc --version. The output in my PC was libprotoc 3.9.0
  6. Create a simple .proto file with the following content
package api;

service HiService{
    rpc SayHi (HiRequest) returns (HiResponse);
}

message HiRequest{
    string hi = 1;
}

message HiResponse{
    string hireply = 1;
}
  1. Run the command protoc --go_out=. firstfile.proto to generate the .pb.go file. The .pb.go file has the below compile time assertion in it that says if the compilation fails at this line, proto package needs to be updated.
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.

const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package 
  1. Compile the .pb.go file with another project (docker for example) and notice the following compilation error.
    undefined: proto.ProtoPackageIsVersion3
    What did you expect to see
    No compilation error. Why is there a need to update the proto version when the version 3.9.0 was installed already (as confirmed in point 5 above). Also, the protoc plugin for Go was installed using the command go get -u github.com/golang/protobuf/protoc-gen-go that should have also installed the latest plugin in place.
    What did you see instead?
    undefined: proto.ProtoPackageIsVersion3
    Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

@niketagrawal
Copy link
Author

Issue is solved after consulting golang/protobuf#763

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

1 participant