grpc-go: undefined: grpc.SupportPackageIsVersion3

The following commit:

commit 727a60e4d135c53c4d62d708ac4528f7c077c0d0
Author: Mak Mukhi <mmukhi@google.com>
Date:   Fri Oct 21 18:06:55 2016 -0700

    update server reflection code to comply with the change to the grpc generator

Introduces the error:

# github.com/org/repo/vendor/some_grpc_lib
vendor/some_grpc_lib/some_lib.pb.go:173: undefined: grpc.SupportPackageIsVersion3`

The error message is not helpful. I have tried regenerating source files using the latest protoc

$ protoc --version
libprotoc 3.1.0

How can this problem be fixed? Can you provide a more helpful error message?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 26 (9 by maintainers)

Most upvoted comments

We are having a nightmare of a time dealing with this issue also.

How do you recommend working through it?

Here’s an example. We have a developer working on project A who generates their gRPC code with grpc.SupportPackageIsVersion3.

A developer working on project B imports the package with the generated gRPC client from project A. Project B also needs to generate a gRPC server but they generate it with grpc.SupportPackageIsVersion4.

Now the project cannot build.

So you suggest re-generating the protofile from Project A, but this feels weird to us. Now we’re changing a vendored file (the generated file) that really should be untouchable since it belongs to Project A.

Also, a lot of our files are difficult to generate in the vendored folder since they rely on imports that are relative to Project’s A repo.

Another alternative is to copy/paste the code in the .proto file from Project A to Project B and have Project B generate its own client code. We’re duplicating that code and separating it though, so this seems less than ideal as well.

What do you suggest? This really is a huge problem for us and I don’t feel like there’s a great solution. If you have a single gRPC dependency you are importing then it might be fairly straight-forward, but when you have several that each have several dependencies of their own it becomes a huge pain.

This is not rocket science. We simply add a variable grpc.SupportPackageIsVersionX (X is the integer and the current value is 4) to make sure your grpc lib and the generated code work on the same version. We think this is a nice feature so that our users won’t blindly mess up different version altogether which may have undefined errors and hard to tackle. In general, if you encounter this problem, check this file (https://github.com/golang/protobuf/blob/master/protoc-gen-go/grpc/grpc.go#L51) and this file (https://github.com/grpc/grpc-go/blob/master/rpc_util.go#L481) for both your project and its dependencies (if they also use gRPC) and see whether they are matched. If they are not, update the repo to make them consistent (you probably need to do additional steps if this happens to your dependencies. I do not want to recommend a way here because this highly depends on your best practice.). Once they are consistent, regenerate all the code. The problem should go away.

@troylelandshields Yes it is a huge pain if your project has a deep dependency tree. But this pain is not specific to grpc. Basically it applies to all the libraries which are used in multiple places in the dependency tree. I think the library should ship with its vendored grpc library, which makes the life much easier.

@iamqizhao thank you for reminding me that it’s not rocket science.

My point is simply that other non-rocket-scientist people are going to run into this issue as gRPC and Go increase in popularity. They are going to be coming here to look for answers or ask for help as well.

Obviously a lot of thought was put into the decision to add this feature so I think it was fair to assume that we were doing something wrong and you guys must have had a best practice in mind for dealing with this. Apparently the best practice is “deal with it,” which is pretty unsatisfactory but we’ll figure it out.

You need to be like Google and work out of one giant repo for all projects… :troll:

@MakMukhi I just moved aside my entire $GOPATH, reinstalled from scratch, and am getting the same error. Can you not reproduce? Does this show that the issue is not on my end, but rather upstream? Anything else I should try?

 ~ $ echo $GOPATH
/Users/<user>/golang
 ~ $ mv -v $GOPATH $GOPATH.bak
/Users/<user>/golang -> /Users/<user>/golang.bak
 ~ $ which -a protoc-gen-go
 ! ~ $ go get -u -v github.com/golang/protobuf/{proto,protoc-gen-go}
github.com/golang/protobuf (download)
github.com/golang/protobuf/proto
github.com/golang/protobuf/protoc-gen-go/descriptor
github.com/golang/protobuf/protoc-gen-go/plugin
github.com/golang/protobuf/protoc-gen-go/generator
github.com/golang/protobuf/protoc-gen-go/grpc
github.com/golang/protobuf/protoc-gen-go
 ~ $ which -a protoc-gen-go
/Users/<user>/golang/bin/protoc-gen-go
 ~ $ go get -u -v google.golang.org/grpc
Fetching https://google.golang.org/grpc?go-get=1
Parsing meta tags from https://google.golang.org/grpc?go-get=1 (status code 200)
get "google.golang.org/grpc": found meta tag main.metaImport{Prefix:"google.golang.org/grpc", VCS:"git", RepoRoot:"https://github.com/grpc/grpc-go"} at https://google.golang.org/grpc?go-get=1
google.golang.org/grpc (download)
github.com/golang/protobuf (download)
Fetching https://golang.org/x/net/context?go-get=1
Parsing meta tags from https://golang.org/x/net/context?go-get=1 (status code 200)
get "golang.org/x/net/context": found meta tag main.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/context?go-get=1
get "golang.org/x/net/context": verifying non-authoritative meta tag
Fetching https://golang.org/x/net?go-get=1
Parsing meta tags from https://golang.org/x/net?go-get=1 (status code 200)
golang.org/x/net (download)
Fetching https://golang.org/x/net/http2?go-get=1
Parsing meta tags from https://golang.org/x/net/http2?go-get=1 (status code 200)
get "golang.org/x/net/http2": found meta tag main.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/http2?go-get=1
get "golang.org/x/net/http2": verifying non-authoritative meta tag
Fetching https://golang.org/x/net/http2/hpack?go-get=1
Parsing meta tags from https://golang.org/x/net/http2/hpack?go-get=1 (status code 200)
get "golang.org/x/net/http2/hpack": found meta tag main.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/http2/hpack?go-get=1
get "golang.org/x/net/http2/hpack": verifying non-authoritative meta tag
Fetching https://golang.org/x/net/idna?go-get=1
Parsing meta tags from https://golang.org/x/net/idna?go-get=1 (status code 200)
get "golang.org/x/net/idna": found meta tag main.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/idna?go-get=1
get "golang.org/x/net/idna": verifying non-authoritative meta tag
Fetching https://golang.org/x/net/lex/httplex?go-get=1
Parsing meta tags from https://golang.org/x/net/lex/httplex?go-get=1 (status code 200)
get "golang.org/x/net/lex/httplex": found meta tag main.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/lex/httplex?go-get=1
get "golang.org/x/net/lex/httplex": verifying non-authoritative meta tag
Fetching https://golang.org/x/net/trace?go-get=1
Parsing meta tags from https://golang.org/x/net/trace?go-get=1 (status code 200)
get "golang.org/x/net/trace": found meta tag main.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/trace?go-get=1
get "golang.org/x/net/trace": verifying non-authoritative meta tag
Fetching https://golang.org/x/net/internal/timeseries?go-get=1
Parsing meta tags from https://golang.org/x/net/internal/timeseries?go-get=1 (status code 200)
get "golang.org/x/net/internal/timeseries": found meta tag main.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/internal/timeseries?go-get=1
get "golang.org/x/net/internal/timeseries": verifying non-authoritative meta tag
Fetching https://google.golang.org/grpc/codes?go-get=1
Parsing meta tags from https://google.golang.org/grpc/codes?go-get=1 (status code 200)
get "google.golang.org/grpc/codes": found meta tag main.metaImport{Prefix:"google.golang.org/grpc", VCS:"git", RepoRoot:"https://github.com/grpc/grpc-go"} at https://google.golang.org/grpc/codes?go-get=1
get "google.golang.org/grpc/codes": verifying non-authoritative meta tag
Fetching https://google.golang.org/grpc?go-get=1
Parsing meta tags from https://google.golang.org/grpc?go-get=1 (status code 200)
Fetching https://google.golang.org/grpc/credentials?go-get=1
Parsing meta tags from https://google.golang.org/grpc/credentials?go-get=1 (status code 200)
get "google.golang.org/grpc/credentials": found meta tag main.metaImport{Prefix:"google.golang.org/grpc", VCS:"git", RepoRoot:"https://github.com/grpc/grpc-go"} at https://google.golang.org/grpc/credentials?go-get=1
get "google.golang.org/grpc/credentials": verifying non-authoritative meta tag
Fetching https://google.golang.org/grpc/grpclog?go-get=1
Parsing meta tags from https://google.golang.org/grpc/grpclog?go-get=1 (status code 200)
get "google.golang.org/grpc/grpclog": found meta tag main.metaImport{Prefix:"google.golang.org/grpc", VCS:"git", RepoRoot:"https://github.com/grpc/grpc-go"} at https://google.golang.org/grpc/grpclog?go-get=1
get "google.golang.org/grpc/grpclog": verifying non-authoritative meta tag
Fetching https://google.golang.org/grpc/internal?go-get=1
Parsing meta tags from https://google.golang.org/grpc/internal?go-get=1 (status code 200)
get "google.golang.org/grpc/internal": found meta tag main.metaImport{Prefix:"google.golang.org/grpc", VCS:"git", RepoRoot:"https://github.com/grpc/grpc-go"} at https://google.golang.org/grpc/internal?go-get=1
get "google.golang.org/grpc/internal": verifying non-authoritative meta tag
Fetching https://google.golang.org/grpc/metadata?go-get=1
Parsing meta tags from https://google.golang.org/grpc/metadata?go-get=1 (status code 200)
get "google.golang.org/grpc/metadata": found meta tag main.metaImport{Prefix:"google.golang.org/grpc", VCS:"git", RepoRoot:"https://github.com/grpc/grpc-go"} at https://google.golang.org/grpc/metadata?go-get=1
get "google.golang.org/grpc/metadata": verifying non-authoritative meta tag
Fetching https://google.golang.org/grpc/naming?go-get=1
Parsing meta tags from https://google.golang.org/grpc/naming?go-get=1 (status code 200)
get "google.golang.org/grpc/naming": found meta tag main.metaImport{Prefix:"google.golang.org/grpc", VCS:"git", RepoRoot:"https://github.com/grpc/grpc-go"} at https://google.golang.org/grpc/naming?go-get=1
get "google.golang.org/grpc/naming": verifying non-authoritative meta tag
Fetching https://google.golang.org/grpc/stats?go-get=1
Parsing meta tags from https://google.golang.org/grpc/stats?go-get=1 (status code 200)
get "google.golang.org/grpc/stats": found meta tag main.metaImport{Prefix:"google.golang.org/grpc", VCS:"git", RepoRoot:"https://github.com/grpc/grpc-go"} at https://google.golang.org/grpc/stats?go-get=1
get "google.golang.org/grpc/stats": verifying non-authoritative meta tag
Fetching https://google.golang.org/grpc/tap?go-get=1
Parsing meta tags from https://google.golang.org/grpc/tap?go-get=1 (status code 200)
get "google.golang.org/grpc/tap": found meta tag main.metaImport{Prefix:"google.golang.org/grpc", VCS:"git", RepoRoot:"https://github.com/grpc/grpc-go"} at https://google.golang.org/grpc/tap?go-get=1
get "google.golang.org/grpc/tap": verifying non-authoritative meta tag
Fetching https://google.golang.org/grpc/transport?go-get=1
Parsing meta tags from https://google.golang.org/grpc/transport?go-get=1 (status code 200)
get "google.golang.org/grpc/transport": found meta tag main.metaImport{Prefix:"google.golang.org/grpc", VCS:"git", RepoRoot:"https://github.com/grpc/grpc-go"} at https://google.golang.org/grpc/transport?go-get=1
get "google.golang.org/grpc/transport": verifying non-authoritative meta tag
Fetching https://google.golang.org/grpc/peer?go-get=1
Parsing meta tags from https://google.golang.org/grpc/peer?go-get=1 (status code 200)
get "google.golang.org/grpc/peer": found meta tag main.metaImport{Prefix:"google.golang.org/grpc", VCS:"git", RepoRoot:"https://github.com/grpc/grpc-go"} at https://google.golang.org/grpc/peer?go-get=1
get "google.golang.org/grpc/peer": verifying non-authoritative meta tag
golang.org/x/net/context
golang.org/x/net/http2/hpack
golang.org/x/net/idna
golang.org/x/net/internal/timeseries
google.golang.org/grpc/codes
golang.org/x/net/lex/httplex
google.golang.org/grpc/credentials
google.golang.org/grpc/grpclog
golang.org/x/net/trace
google.golang.org/grpc/internal
golang.org/x/net/http2
google.golang.org/grpc/metadata
google.golang.org/grpc/naming
google.golang.org/grpc/stats
google.golang.org/grpc/tap
google.golang.org/grpc/peer
google.golang.org/grpc/transport
google.golang.org/grpc
 ~ $ cd src/cloud-grpc/start/
 ~/s/cloud-grpc  master  start $ go run client.go
# _/Users/<user>/src/cloud-grpc/start/books
books/books.pb.go:107: undefined: grpc.SupportPackageIsVersion3

I guess your vendored gRPC is outdated. And did you try to regenerate the file you mentioned vendor/some_grpc_lib/some_lib.pb.go?