Protobuf: grpc version conflict

Created on 3 Dec 2016  路  3Comments  路  Source: golang/protobuf

When I am building a proto (with grpc enabled) using bazel, I am getting this error message:

undefined: grpc.SupportPackageIsVersion4.

The reason for this error seems to be:

  • I am using multiple 3rd party Golang repositories like {org_golang_google_api, com_google_cloud_go, com_github_googleapis_gax_go}, whose HEADs contain protos built with grpc.SupportPackageIsVersion3.
  • And I have to use the most recent version of com_github_golang_protobuf, which is using grpc.SupportPackageIsVersion4.

Is there anyway to handle this issue?

Thanks.

Most helpful comment

For those who want to fix this issue temporarily, I have fixed it by following these steps:

  1. Change generatedCodeVersion from 4 to 3

    $ cd $GOPATH/src/github.com/golang/protobuf/protoc-gen-go
    $ vi grpc/grpc.go
    // generatedCodeVersion indicates a version of the generated code.
    // It is incremented whenever an incompatibility between the generated code and
    // the grpc package is introduced; the generated code references
    // a constant, grpc.SupportPackageIsVersionN (where N is generatedCodeVersion).
    const generatedCodeVersion = 3
    
  2. Recompile protoc-gen-go

    # cd $GOPATH/src/github.com/golang/protobuf/protoc-gen-go
    $ go install
    
  3. Now use protoc as normal

All 3 comments

Multiple people have had this issue. So far it hasn't really been addressed to a satisfactory solution IMHO.

For those who want to fix this issue temporarily, I have fixed it by following these steps:

  1. Change generatedCodeVersion from 4 to 3

    $ cd $GOPATH/src/github.com/golang/protobuf/protoc-gen-go
    $ vi grpc/grpc.go
    // generatedCodeVersion indicates a version of the generated code.
    // It is incremented whenever an incompatibility between the generated code and
    // the grpc package is introduced; the generated code references
    // a constant, grpc.SupportPackageIsVersionN (where N is generatedCodeVersion).
    const generatedCodeVersion = 3
    
  2. Recompile protoc-gen-go

    # cd $GOPATH/src/github.com/golang/protobuf/protoc-gen-go
    $ go install
    
  3. Now use protoc as normal

Fundamentally, the Go ecosystem needs a proper dependency management system, which is finally in the works. The proper approach to this issue is proper version tagging. Closing this in favor of #328

Was this page helpful?
0 / 5 - 0 ratings