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

AnnotateIncomingContext not declared by package runtime #1023

Closed
alexanderjophus opened this issue Sep 2, 2019 · 4 comments
Closed

AnnotateIncomingContext not declared by package runtime #1023

alexanderjophus opened this issue Sep 2, 2019 · 4 comments

Comments

@alexanderjophus
Copy link

alexanderjophus commented Sep 2, 2019

Steps you follow to reproduce the error:

curl -sSL https://github.com/uber/prototool/releases/download/v1.8.0/prototool-$(shell uname -s)-$(shell uname -m) -o /usr/local/bin/prototool
chmod +x /usr/local/bin/prototool
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u github.com/golang/protobuf/protoc-gen-go

Compile code

What did you expect to happen instead:

It to compile correctly

What's your theory on why it isn't working:

proto/gen/go/service/front.pb.gw.go:73:24: AnnotateIncomingContext not declared by package runtime (typecheck)
		rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)

There is a new commit that has AnnotateIncomingContext declared in the runtime package. Releasing a new version with that commit in should solve the problem

@johanbrandhorst
Copy link
Collaborator

Hi @trelore. This is a consequence of using go get to install the generator while using a dependency management tool to version the runtime. The runtime package and generator must be using the same version. There are two ways to solve your issue:

  1. Version the generators, too.
    For example using deps required or go modules tool dependencies.
  2. Use master for both the generators and the runtime.

Speaking from experience with other users running into this problem though, I'm gonna make release 1.11.1.

@metrue
Copy link

metrue commented Sep 27, 2019

@johanbrandhorst

I also met the same issue, can you clarify a little bit more on,

There are two ways to solve your issue:

  1. Version the generators, too.
    For example using deps required or go modules tool dependencies.
  2. Use master for both the generators and the runtime.

I'm using the commands provided from README to do the installation,

go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u github.com/golang/protobuf/protoc-gen-go

I am sure the runtime and generators should be updated to date and align with each other right?

@johanbrandhorst
Copy link
Collaborator

johanbrandhorst commented Sep 27, 2019

Hi Minghe,

Yeah so if you're using go modules you don't want to be using those commands, because they will all update independently and also update all downstream dependencies. What you want to do is add a tool dependency for github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway and github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger and then just run

$ go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gatewaygithub.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger

It will use the versions from your go.mod file, which will be the same as the version of the runtime (which should also be tracked in your go.mod file, of course).

Does that help?

@austincollinpena
Copy link

I ran into this issue, here was my fix. I checked my go.mod file and saw that I was running v1.9 for some reason. I manually changed the version number to the version installed to my gopath.

All fixed.

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

4 participants