Goclient and vendor mismatch issues

Some of our users faced an issue while trying to run the Go client. I did some analysis about the issue to find the actual cause. What I found is that if you are trying to build the goclient outside the dgraph repo, say I try it in $GOPATH/src/github.com/pawanrawal/someapp, I get the error

./main.go:55: cannot use conn (type *"google.golang.org/grpc".ClientConn) as type *"github.com/dgraph-io/dgraph/vendor/google.golang.org/grpc".ClientConn in argument to graph.NewDgraphClient
./main.go:122: cannot use conn (type *"google.golang.org/grpc".ClientConn) as type *"github.com/dgraph-io/dgraph/vendor/google.golang.org/grpc".ClientConn in argument to graph.NewDgraphClient

What happens here is that Go can’t figure out that the grpc version in my GOPATH and that in the vendor directory of Dgraph repo is the same. Hence this error. A version of the similar issue has been faced by other users too

  1. vendor: go build error when in some dependence · Issue #12432 · golang/go · GitHub
  2. vendor: go build error when there are multi instances of one package in vendor/ · Issue #73 · Masterminds/glide · GitHub

So when our users try to do a go get -v github.com/dgraph-io/dgraph/query/graph, the vendored versions are of grpc and context package are downloaded as you can see below because they are vendored in.

github.com/dgraph-io/dgraph/vendor/golang.org/x/net/context
github.com/dgraph-io/dgraph/vendor/golang.org/x/net/trace
github.com/dgraph-io/dgraph/vendor/google.golang.org/grpc/credentials
github.com/dgraph-io/dgraph/vendor/google.golang.org/grpc/metadata
github.com/dgraph-io/dgraph/vendor/google.golang.org/grpc/stats
github.com/dgraph-io/dgraph/vendor/google.golang.org/grpc/tap
github.com/dgraph-io/dgraph/vendor/google.golang.org/grpc/peer
github.com/dgraph-io/dgraph/vendor/google.golang.org/grpc/transport
github.com/dgraph-io/dgraph/vendor/google.golang.org/grpc
github.com/dgraph-io/dgraph/query/graph

And now go build would cause an error if you try to use the Go client. The only solution I found for this was to not vendor in the grpc package, so that while downloading the graph package, the actual grpc package is downloaded and not the vendored version. What do you think @minions?

Raise this in the Go discourse forum. This seems like a Go issue.

Seems like not vendoring in gRPC and its sub packages is our only solution here.

1 Like

I think there is similar issue in dgraph repo as well.

You mean the issue where forking Dgraph and building it doesn’t work?

Yes, building from forked dgraph fails to compile.

in #slack-general channel, gpsamson had this issue :

gpsamson
8:08 AM
I’m getting an error when trying to build my fork of the master branch `./main.go:644: cannot use s (type *"github.com/gpsamson/dgraph/vendor/google.golang.org/grpc".Server) as type *"github.com/dgraph-io/dgraph/vendor/google.golang.org/grpc"`
8:09
Am I missing a step? I just forked, cloned the fork, cd cmd/dgraph, go build

I have added a task for this and will have a look. Thanks @ashish.

Added instructions https://wiki.dgraph.io/Contributing_to_Dgraph#Forking_Dgraph on how to work with forked repos.

Hi all,

I updated my dgraph version today, so naturally I ran into this issue. I solved the issue as prescribed - by deleting the relevant vendored dependencies - however, there is barely any mention of this in official documentation about the Go client here: https://docs.dgraph.io/v0.7.5/clients/#go. Is this something that’s being added at the moment? I think it would be pretty painful new people to deal with this bug, especially if they weren’t particularly well-versed in Go

Thanks for reporting. Can you go to that page in docs, and either file a github issue, or send a PR to fix the documentation. Both would be much appreciated.

Manish,

Sure, I’ll make a PR soon then :smiley:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.