tools / godep

dependency tool for go
http://godoc.org/github.com/tools/godep
BSD 3-Clause "New" or "Revised" License
5.54k stars 454 forks source link

godep save ./... can run into impossible situation to resolve with /vendor/ folders. #421

Closed dmitshur closed 8 years ago

dmitshur commented 8 years ago

This is in response to https://github.com/tools/godep/commit/2b89290b55d5d1b2dcef9129f7c42038070d11b4#commitcomment-16286468.

Using godep v55 (darwin/amd64/go1.6).

In our case (we have some old dependencies vendored), it's causing trouble to do godep save ./... in the repo, while godep save $(go list ./... | grep -v /vendor/) works. The error message I get is:

$ godep save ./...
godep: Package (github.com/docker/docker/pkg/units) not found

None of this repository's code actually imports that or needs that package (it's really old and got moved elsewhere by now), but it is vendored in a very old version of another dependency we have vendored:

$GOPATH/src/github.com/drone/drone/vendor/github.com/samalba/dockerclient/types.go:
    6   "time"
    7  
    8:  "github.com/docker/docker/pkg/units"
    9  )
   10  

And doing godep save ./... tries to vendor it, but fails since it doesn't exist in the github.com/docker/docker repo we have vendored.

In fact, you can see this problem in the very latest master (as of right now) of github.com/docker/docker github.com/drone/drone repo.

https://github.com/drone/drone/blob/670217ac1b7ab19525cf4b584a982cada4b1ea6f/vendor/github.com/samalba/dockerclient/types.go

As you can see, that github.com/drone/drone repo has a /vendor/ folder with a vendored copy of github.com/samalba/dockerclient repo, which has a types.go file that imports:

"github.com/docker/docker/pkg/units"

But that import path does not exist in 670217ac1b7ab19525cf4b584a982cada4b1ea6f of github.com/docker/docker.

And I think that's tripping godep save ./.... Thoughts?

dmitshur commented 8 years ago

Well, I just realized that I confused github.com/docker/docker and github.com/drone/drone because of similar spelling. They are separate repos after all.

dmitshur commented 8 years ago

I'll close this because I made a mistake while figuring out what's going on, so this issue is invalid. There may be a problem with godep save ./... behavior, but what I described above is not a reproducible issue description.

freeformz commented 8 years ago

There are several issues here AFAICT.

  1. github.com/drone/drone does not use godep (there is no metadata file listing the contents of vendor).
  2. godep does not as of yet collapse / pull up all dependencies. This can lead to this problem like here.
  3. godep relies on things being in $GOPATH.
  4. I don't really understand how drone manages these dependencies as there is no Godeps/Godeps.json file, so it's impossible to do a godep restore, which should be done before a re-save.
dmitshur commented 8 years ago

To clarify, the codebase I was referring to (src.sourcegraph.com/sourcegraph/...) imports and uses both github.com/drone/drone/... and github.com/docker/docker/... or parts there-of, and that's where I ran into this issue. You're right, I'm not sure how github.com/drone/drone manages its /vendor/ folder, I don't see Godeps.json, govendor.json, or any other similar file.

freeformz commented 8 years ago

Ahh. Thanks for the clarification.

So the biggest issue is probably because we don’t pull up all deps and flatten them at the top level (yet).

On Feb 23, 2016, at 7:22 PM, Dmitri Shuralyov notifications@github.com wrote:

To clarify, the codebase I was referring to (src.sourcegraph.com/sourcegraph/...) imports and uses both github.com/drone/drone/... and github.com/docker/docker/... or parts there-of. You're right, I'm not sure how github.com/drone/drone manages its /vendor/ folder, I don't see Godeps.json, govendor.json, or any other similar file.

— Reply to this email directly or view it on GitHub https://github.com/tools/godep/issues/421#issuecomment-188041604.