adhocteam / soapbox

Apache License 2.0
11 stars 3 forks source link

Protobuf code generation #167

Closed kalilsn closed 6 years ago

kalilsn commented 6 years ago

When I attempt to generate the go protobuf code, I end up with code that won't compile:

proto/activity.pb.go:91:44: undefined: proto.InternalMessageInfo
proto/activity.pb.go:135:30: undefined: proto.InternalMessageInfo
proto/activity.pb.go:220:13: c.cc.Invoke undefined (type *grpc.ClientConn has no field or method Invoke)
proto/activity.pb.go:229:13: c.cc.Invoke undefined (type *grpc.ClientConn has no field or method Invoke)
proto/activity.pb.go:238:13: c.cc.Invoke undefined (type *grpc.ClientConn has no field or method Invoke)
proto/activity.pb.go:247:13: c.cc.Invoke undefined (type *grpc.ClientConn has no field or method Invoke)
proto/application.pb.go:150:33: undefined: proto.InternalMessageInfo
proto/application.pb.go:279:44: undefined: proto.InternalMessageInfo
proto/application.pb.go:317:45: undefined: proto.InternalMessageInfo
proto/application.pb.go:355:43: undefined: proto.InternalMessageInfo
proto/application.pb.go:355:43: too many errors

https://github.com/grpc/grpc-go/issues/2095 suggested that it was due to a version mismatch, but after updating all of the protobuf dependencies (including the project local grpc with dep), I get the exact same code and compilation errors.

paulsmith commented 6 years ago

@kalilsn What does the output of protoc --version say?

kalilsn commented 6 years ago

libprotoc 3.6.0

paulsmith commented 6 years ago

OK, I have libprotoc 3.4.0, and I can't reproduce this bug.

I'll try upgrading my protoc and c what happens.

kalilsn commented 6 years ago

I pushed up a branch with the bad code: https://github.com/adhocteam/soapbox/tree/kalilsn/update-dependencies

I've noticed now that github.com/golang/protobuf wasn't updated to a newer revision (https://github.com/adhocteam/soapbox/blob/kalilsn/update-dependencies/Gopkg.lock#L60). I can't really tell from the lockfile where this dependency comes from, although I would have assumed it was grpc, since the only other dependency in our Gopkg.toml is pq. Perhaps I'm updating the dependencies incorrectly? I ran dep ensure -update google.golang.org/grpc.

paulsmith commented 6 years ago

I added the dependency to google.golang.org/grpc, because that package is needed to generate the Go code from protobufs for gRPC. I don't think we should update the version unless there is a compelling reason. Have you tried setting it back to the original version, re-ensure'ing via dep, and re-compiling from there?

kalilsn commented 6 years ago

I agree, I was only updating those dependencies because that issue suggested that some kind of mismatch might cause this. The original compilation error I posted was on the master branch after running dep ensure and then make protobufs. I just checked it out again to confirm.

paulsmith commented 6 years ago

Ah, I think I understand what's up. Stand by.

paulsmith commented 6 years ago

@kalilsn If you blow away your soapbox dir and do a clean git clone and make all on master, does it succeed?

kalilsn commented 6 years ago

make all succeeds, but if I run make protobufs first, then it fails in the same way.

kalilsn commented 6 years ago

@orenfromberg managed to get it to build by updating grpc, adding an explicit dependency on github.com/golang/protobuf, and making a small change to a line in soapboxd/deployment.go https://github.com/adhocteam/soapbox/compare/oren/protoc-fix

@paulsmith are you ok with updating grpc in this case?

paulsmith commented 6 years ago

@kalilsn OK, I tried Oren's branch and it worked for me. I suspect that the drift in github.com/golang/protobuf is the root cause here, so ordinarily I would prefer that we lock to the version that worked before, but I'm okay with rolling forward on grpc version in interest of moving on.

kalilsn commented 6 years ago

Fixed by #168