Dep: `dep ensure` pulls malformed subpackage

Created on 9 Aug 2017  ยท  6Comments  ยท  Source: golang/dep

What version of Go (go version) and dep (git describe --tags) are you using?

go version go1.9rc1 darwin/amd64
dep v0.3.0-34-gc80fab8

What dep command did you run?

$ git clone https://github.com/VojtechVitek/dep-test.git

$ cd dep-test

$ cat Gopkg.toml
[[constraint]]
  name = "github.com/go-chi/docgen/raml"
  version = "^1.0.2"

$ dep ensure -v
Root project is "github.com/VojtechVitek/dep-test"
 1 transitively valid internal packages
 1 external packages imported from 1 projects
(0)   โœ“ select (root)
(1) ? attempt github.com/go-chi/docgen/raml with 1 pkgs; 4 versions to try
(1)     try github.com/go-chi/docgen/[email protected]
(1) โœ“ select github.com/go-chi/docgen/[email protected] w/1 pkgs
(2) ? attempt github.com/go-chi/chi with 1 pkgs; 16 versions to try
(2)     try github.com/go-chi/[email protected]
(2) โœ“ select github.com/go-chi/[email protected] w/1 pkgs
  โœ“ found solution with 2 packages from 2 projects

Solver wall times by segment:
     b-source-exists: 1.731622899s
         b-list-pkgs: 477.610861ms
              b-gmal: 448.395904ms
             satisfy:    366.948ยตs
         select-atom:    328.329ยตs
            new-atom:    137.822ยตs
         select-root:     63.428ยตs
     b-list-versions:     56.773ยตs
  b-deduce-proj-root:     28.949ยตs
               other:     13.635ยตs

  TOTAL: 2.658625548s

What did you expect to see?

  • dep should have installed github.com/go-chi/docgen/raml subpkg
  • dep should have installed github.com/go-chi/docgen transitive dependency pkg

What did you see instead?

vendor/
โ””โ”€โ”€ github.com
    โ””โ”€โ”€ go-chi
        โ””โ”€โ”€ docgen
            โ””โ”€โ”€ raml               <=== This directory is wrong. All the files should have been in the parent directory instead.
                โ”œโ”€โ”€ LICENSE
                โ”œโ”€โ”€ builder.go
                โ”œโ”€โ”€ docgen.go
                โ”œโ”€โ”€ docgen_test.go
                โ”œโ”€โ”€ funcinfo.go
                โ”œโ”€โ”€ markdown.go
                โ”œโ”€โ”€ raml           <=== Um, what? Yet another raml subdirectory?
                โ”‚ย ย  โ”œโ”€โ”€ raml.go
                โ”‚ย ย  โ””โ”€โ”€ raml_test.go
                โ””โ”€โ”€ util.go
$ dep status
PROJECT                        CONSTRAINT  VERSION  REVISION  LATEST   PKGS USED
github.com/go-chi/chi          *           v3.1.5   25354a5   25354a5  1
github.com/go-chi/docgen/raml  ^1.0.2      v1.0.2   ac43d9a   ac43d9a  1

Reproducer repo: https://github.com/VojtechVitek/dep-test

bug ensure

Most helpful comment

$ dep ensure -v
The following issues were found in Gopkg.toml:

  โœ— the name for "github.com/go-chi/docgen/raml" should be changed to "github.com/go-chi/docgen"

ProjectRoot name validation failed

Thanks for fixing this!

All 6 comments

hi hi - so this is the problem:

$ cat Gopkg.toml
[[constraint]]
  name = "github.com/go-chi/docgen/raml"
  version = "^1.0.2"

that's not a project root; github.com/go-chi/docgen is. all constraints declared in Gopkg.toml have to be on a root, or we see _weird_ behavior, like this.

clearly this is something that needs enforcement - which is why we have...huh. weird. i thought we did this in #697, but it seems not. @ibrasho, do we have something open for this?

@sdboyer yea, I figured the problem would be the non-root dependency path in Gopkg.toml.

So, how do I vendor github.com/go-chi/docgen/raml subpkg again? Do I need to vendor root package and then dep prune to get rid of any unused pkgs? Imho, this needs better documentation and error messages.

So, how do I vendor github.com/go-chi/docgen/raml subpkg again?

you just import it, and dep ensure (and dep prune if that matters for your use pattern). you're overthinking it ๐Ÿ˜„

the rules declared in Gopkg.toml are only for applying version constraints or alternate sources. they don't _have_ to be there at all for your dependencies to be satisfied, though it's generally preferable that they're there.

what kind of doc heading would you expect to find this information under?

@sdboyer How about adding root path check in manifest validation function?
When ensure and status try to load manifest via dep.Ctx they can fail to load with error message.

@darkowlzz yes, we definitely need that. what's weird is, i thought we'd added it in an earlier PR by @ibrasho - but it seems to not be there :/

$ dep ensure -v
The following issues were found in Gopkg.toml:

  โœ— the name for "github.com/go-chi/docgen/raml" should be changed to "github.com/go-chi/docgen"

ProjectRoot name validation failed

Thanks for fixing this!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

deejross picture deejross  ยท  3Comments

alethenorio picture alethenorio  ยท  3Comments

jjyr picture jjyr  ยท  3Comments

jeffwillette picture jeffwillette  ยท  3Comments

rustyx picture rustyx  ยท  3Comments