yudai / gojsondiff

Go JSON Diff
Other
535 stars 81 forks source link

Missing dependencies in vendor/ #16

Closed ryboe closed 7 years ago

ryboe commented 7 years ago
$ cd $GOPATH/src/github.com/yudai/gojsondiff
$ go test ./...
vendor/github.com/yudai/gojsondiff/deltas.go:5:2: cannot find package "github.com/sergi/go-diff/diffmatchpatch" in any of:
    /Users/ryan/go2/src/foo/vendor/github.com/yudai/gojsondiff/vendor/github.com/sergi/go-diff/diffmatchpatch (vendor tree)
    /Users/ryan/go2/src/foo/vendor/github.com/sergi/go-diff/diffmatchpatch
    /usr/local/Cellar/go/1.8/libexec/src/github.com/sergi/go-diff/diffmatchpatch (from $GOROOT)
    /Users/ryan/go2/src/github.com/sergi/go-diff/diffmatchpatch (from $GOPATH)
vendor/github.com/yudai/gojsondiff/gojsondiff.go:13:2: cannot find package "github.com/yudai/golcs" in any of:
    /Users/ryan/go2/src/foo/vendor/github.com/yudai/gojsondiff/vendor/github.com/yudai/golcs (vendor tree)
    /Users/ryan/go2/src/foo/vendor/github.com/yudai/golcs
    /usr/local/Cellar/go/1.8/libexec/src/github.com/yudai/golcs (from $GOROOT)
    /Users/ryan/go2/src/github.com/yudai/golcs (from $GOPATH)
vendor/github.com/yudai/gojsondiff/jd/main.go:9:2: cannot find package "github.com/codegangsta/cli" in any of:
    /Users/ryan/go2/src/foo/vendor/github.com/yudai/gojsondiff/vendor/github.com/codegangsta/cli (vendor tree)
    /Users/ryan/go2/src/foo/vendor/github.com/codegangsta/cli
    /usr/local/Cellar/go/1.8/libexec/src/github.com/codegangsta/cli (from $GOROOT)
    /Users/ryan/go2/src/github.com/codegangsta/cli (from $GOPATH)
vendor/github.com/yudai/gojsondiff/tests/helper.go:4:2: cannot find package "github.com/onsi/ginkgo" in any of:
    /Users/ryan/go2/src/foo/vendor/github.com/yudai/gojsondiff/vendor/github.com/onsi/ginkgo (vendor tree)
    /Users/ryan/go2/src/foo/vendor/github.com/onsi/ginkgo
    /usr/local/Cellar/go/1.8/libexec/src/github.com/onsi/ginkgo (from $GOROOT)
    /Users/ryan/go2/src/github.com/onsi/ginkgo (from $GOPATH)

This is with a clean $GOPATH (a $GOPATH that contains gojsondiff and nothing else).

The problem

These deps are not in vendor/.

github.com/sergi/go-diff/diffmatchpatch
github.com/yudai/golcs
github.com/codegangsta/cli

This dep appears to be in vendor/, but Go is having trouble finding it for some reason. Perhaps the vendoring of that pkg is incomplete.

github.com/onsi/ginkgo

The real problem

You thought everything was vendored because you have everything in your Godeps.json manifest and you ran godep restore. Unfortunately, godep is a first-gen vendoring tool with all sorts of surprising behavior. I could submit a PR to just add the missing deps, but that still leaves us with the problem of why ginkgo isn't being found, and it doesn't prevent future problems should you decide to add/remove deps.

The real solution

A better solution is to revendor the deps using a better vendoring tool, such as Glide or gvt, so that this problem doesn't happen again. This is what I've done in #17 . In the process of revendoring gojsondiff I discovered some other issues which are detailed in the PR notes.

Who I am

I'm the "vendoring guy" at a company called Apcera. We're using gojsondiff internally (thanks very much for writing it!). I discovered this issue when I tried to vendor gojsondiff itself and it didn't work.

yudai commented 7 years ago

Thank you so much!