Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

dep ensure pulls malformed subpackage #984

Closed
VojtechVitek opened this issue Aug 9, 2017 · 6 comments · Fixed by #1116
Closed

dep ensure pulls malformed subpackage #984

VojtechVitek opened this issue Aug 9, 2017 · 6 comments · Fixed by #1116

Comments

@VojtechVitek
Copy link

VojtechVitek commented Aug 9, 2017

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

@sdboyer
Copy link
Member

sdboyer commented Aug 9, 2017

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?

@VojtechVitek
Copy link
Author

@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.

@sdboyer
Copy link
Member

sdboyer commented Aug 9, 2017

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?

@darkowlzz
Copy link
Collaborator

@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.

@sdboyer
Copy link
Member

sdboyer commented Aug 12, 2017

@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 :/

@VojtechVitek
Copy link
Author

$ 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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants