dep ensure returns misleading error at times

Created on 4 Apr 2018  Â·  4Comments  Â·  Source: golang/dep

What version of dep are you using (dep version)?

0.4.1

What dep command did you run?

dep ensure

What did you expect to see?

No errors

What did you see instead?

$ dep ensure
Warning: the following project(s) have [[constraint]] stanzas in Gopkg.toml:

  ✗  github.com/DataDog/datadog-go

However, these projects are not direct dependencies of the current project:
they are not imported in any .go files, nor are they in the 'required' list in
Gopkg.toml. Dep only applies [[constraint]] rules to direct dependencies, so
these rules will have no effect.

Either import/require packages from these projects so that they become direct
dependencies, or convert each [[constraint]] to an [[override]] to enforce rules
on these projects, if they happen to be transitive dependencies,

Alas, this message is wrong. github.com/DataDog/datadog-go is a direct dependency. The problem becomes clearer when one runs dep ensure -v:

$ dep ensure -v
found 1 errors in the package tree:
/go/src/XXX/Dockerfile.go:1:1: expected 'package', found 'IDENT' FROM (and 7 more errors)
Warning: the following project(s) have [[constraint]] stanzas in Gopkg.toml:

  ✗  github.com/DataDog/datadog-go

However, these projects are not direct dependencies of the current project:
they are not imported in any .go files, nor are they in the 'required' list in
Gopkg.toml. Dep only applies [[constraint]] rules to direct dependencies, so
these rules will have no effect.
...

If for some reason there is what appears to be a go file that dep fails to parse, then rather than exit with an appropriate error, it appears that it stops processing other go files but that it attempts to continues checking the dependencies, leading to the wrong message if the dependency import is in one of the go files that it skipped.

Most helpful comment

i'm getting the same issue too

All 4 comments

i'm getting the same issue too

Downgrading to v0.3.2 fixed this problem for me.

same issue with v0.5.0

Dep was officially deprecated earlier this year, and the proposal to archive this repository was accepted. As such, I'm closing outstanding issues before archiving the repository. For any further comments, please use the proposal thread on the Go issue tracker. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kardianos picture kardianos  Â·  43Comments

sdboyer picture sdboyer  Â·  119Comments

sdboyer picture sdboyer  Â·  46Comments

godcong picture godcong  Â·  27Comments

sdboyer picture sdboyer  Â·  40Comments