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

Branch constraint is ignored without warning if specified branch does not exist #1090

Closed
sttts opened this issue Aug 30, 2017 · 2 comments
Closed

Comments

@sttts
Copy link

sttts commented Aug 30, 2017

Compare https://github.com/sttts/kube-vendor-test/tree/ignored-constraint. I put a constraint on apimachinery to select a non-existing branch. This does not lead to a warning or error.

If I happen to import an apimachinery packages instead, the constraint is considered and dep fails.

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

d8d1205

What dep command did you run?

dep ensure -v

What did you expect to see?

An error that my constraint for k8s.io/apimachinery@some-non-existing-branch cannot be fulfilled.

What did you see instead?

The master branch of k8s.io/apimachinery was selected.

Root project is "k8s.io/kube-vendor-test"
 1 transitively valid internal packages
 1 external packages imported from 1 projects
(0)   ✓ select (root)
(1)	? attempt k8s.io/client-go with 1 pkgs; 17 versions to try
(1)	    try k8s.io/client-go@v4.0.0
(1)	✓ select k8s.io/client-go@v4.0.0 w/69 pkgs
(2)	? attempt github.com/golang/glog with 1 pkgs; 1 versions to try
(2)	    try github.com/golang/glog@master
(2)	✓ select github.com/golang/glog@master w/1 pkgs
(3)	? attempt github.com/ugorji/go with 1 pkgs; 1 versions to try
(3)	    try github.com/ugorji/go@master
(3)	✓ select github.com/ugorji/go@master w/1 pkgs
(4)	? attempt github.com/juju/ratelimit with 1 pkgs; 1 versions to try
(4)	    try github.com/juju/ratelimit@master
(4)	✓ select github.com/juju/ratelimit@master w/1 pkgs
(5)	? attempt github.com/go-openapi/spec with 1 pkgs; 2 versions to try
(5)	    try github.com/go-openapi/spec@master
(5)	✓ select github.com/go-openapi/spec@master w/1 pkgs
(6)	? attempt github.com/go-openapi/jsonpointer with 1 pkgs; 1 versions to try
(6)	    try github.com/go-openapi/jsonpointer@master
(6)	✓ select github.com/go-openapi/jsonpointer@master w/1 pkgs
(7)	? attempt github.com/go-openapi/swag with 1 pkgs; 1 versions to try
(7)	    try github.com/go-openapi/swag@master
(7)	✓ select github.com/go-openapi/swag@master w/1 pkgs
(8)	? attempt github.com/go-openapi/jsonreference with 1 pkgs; 1 versions to try
(8)	    try github.com/go-openapi/jsonreference@master
(8)	✓ select github.com/go-openapi/jsonreference@master w/1 pkgs
(9)	? attempt github.com/mailru/easyjson with 2 pkgs; 2 versions to try
(9)	    try github.com/mailru/easyjson@master
(9)	✓ select github.com/mailru/easyjson@master w/3 pkgs
(10)  ? attempt gopkg.in/yaml.v2 with 1 pkgs; 1 versions to try
(10)      try gopkg.in/yaml.v2@v2
(10)  ✓ select gopkg.in/yaml.v2@v2 w/1 pkgs
(11)  ? attempt github.com/gogo/protobuf with 2 pkgs; 17 versions to try
(11)      try github.com/gogo/protobuf@v0.4
(11)  ✓ select github.com/gogo/protobuf@v0.4 w/2 pkgs
(12)  ? attempt github.com/go-openapi/loads with 1 pkgs; 4 versions to try
(12)      try github.com/go-openapi/loads@master
(12)  ✓ select github.com/go-openapi/loads@master w/1 pkgs
(13)  ? attempt github.com/go-openapi/analysis with 1 pkgs; 1 versions to try
(13)      try github.com/go-openapi/analysis@master
(13)  ✓ select github.com/go-openapi/analysis@master w/1 pkgs
(14)  ? attempt github.com/go-openapi/strfmt with 1 pkgs; 3 versions to try
(14)      try github.com/go-openapi/strfmt@master
(14)  ✓ select github.com/go-openapi/strfmt@master w/1 pkgs
(15)  ? attempt github.com/go-openapi/errors with 1 pkgs; 1 versions to try
(15)      try github.com/go-openapi/errors@master
(15)  ✓ select github.com/go-openapi/errors@master w/1 pkgs
(16)  ? attempt github.com/mitchellh/mapstructure with 1 pkgs; 1 versions to try
(16)      try github.com/mitchellh/mapstructure@master
(16)  ✓ select github.com/mitchellh/mapstructure@master w/1 pkgs
(17)  ? attempt gopkg.in/mgo.v2 with 1 pkgs; 1 versions to try
(17)      try gopkg.in/mgo.v2@v2
(17)  ✓ select gopkg.in/mgo.v2@v2 w/2 pkgs
(18)  ? attempt github.com/docker/distribution with 1 pkgs; 62 versions to try
(18)      try github.com/docker/distribution@v2.6.2
(18)  ✓ select github.com/docker/distribution@v2.6.2 w/2 pkgs
(19)  ? attempt github.com/PuerkitoBio/purell with 1 pkgs; 8 versions to try
(19)      try github.com/PuerkitoBio/purell@v1.1.0
(19)  ✓ select github.com/PuerkitoBio/purell@v1.1.0 w/1 pkgs
(20)  ? attempt github.com/PuerkitoBio/urlesc with 1 pkgs; 1 versions to try
(20)      try github.com/PuerkitoBio/urlesc@master
(20)  ✓ select github.com/PuerkitoBio/urlesc@master w/1 pkgs
(21)  ? attempt github.com/emicklei/go-restful-swagger12 with 1 pkgs; 3 versions to try
(21)      try github.com/emicklei/go-restful-swagger12@1.0.1
(21)  ✓ select github.com/emicklei/go-restful-swagger12@1.0.1 w/1 pkgs
(22)  ? attempt golang.org/x/text with 2 pkgs; 1 versions to try
(22)      try golang.org/x/text@master
(22)  ✓ select golang.org/x/text@master w/7 pkgs
(23)  ? attempt github.com/asaskevich/govalidator with 1 pkgs; 8 versions to try
(23)      try github.com/asaskevich/govalidator@v6
(23)  ✓ select github.com/asaskevich/govalidator@v6 w/1 pkgs
(24)  ? attempt golang.org/x/net with 1 pkgs; 5 versions to try
(24)      try golang.org/x/net@master
(24)  ✓ select golang.org/x/net@master w/1 pkgs
(25)  ? revisit golang.org/x/text to add 1 pkgs
(25)    ✓ include 8 more pkgs from golang.org/x/text@master
(25)  ? attempt github.com/emicklei/go-restful with 2 pkgs; 16 versions to try
(26)      try github.com/emicklei/go-restful@v2.2.1
(26)  ✓ select github.com/emicklei/go-restful@v2.2.1 w/2 pkgs
(26)  ? attempt k8s.io/apimachinery with 22 pkgs; 3 versions to try
(27)      try k8s.io/apimachinery@master
(27)  ✓ select k8s.io/apimachinery@master w/43 pkgs
(27)  ? revisit golang.org/x/net to add 1 pkgs
(28)    ✓ include 4 more pkgs from golang.org/x/net@master
(27)  ? attempt gopkg.in/inf.v0 with 1 pkgs; 1 versions to try
(29)      try gopkg.in/inf.v0@v0.9.0
(29)  ✓ select gopkg.in/inf.v0@v0.9.0 w/1 pkgs
(28)  ? attempt github.com/google/gofuzz with 1 pkgs; 1 versions to try
(30)      try github.com/google/gofuzz@master
(30)  ✓ select github.com/google/gofuzz@master w/1 pkgs
(29)  ? attempt github.com/davecgh/go-spew with 1 pkgs; 3 versions to try
(31)      try github.com/davecgh/go-spew@v1.1.0
(31)  ✓ select github.com/davecgh/go-spew@v1.1.0 w/1 pkgs
(30)  ? attempt github.com/ghodss/yaml with 1 pkgs; 2 versions to try
(32)      try github.com/ghodss/yaml@v1.0.0
(32)  ✓ select github.com/ghodss/yaml@v1.0.0 w/1 pkgs
(31)  ? attempt github.com/spf13/pflag with 1 pkgs; 3 versions to try
(33)      try github.com/spf13/pflag@v1.0.0
(33)  ✓ select github.com/spf13/pflag@v1.0.0 w/1 pkgs
  ✓ found solution with 159 packages from 31 projects

Solver wall times by segment:
     b-list-versions: 31.014919119s
         b-list-pkgs:  6.356285414s
              b-gmal:  4.234080636s
     b-source-exists:  3.908595554s
  b-deduce-proj-root:  935.530443ms
             satisfy:   23.351522ms
         select-atom:   20.991683ms
            new-atom:     872.411µs
               other:     165.245µs
         select-root:      65.407µs
            add-atom:      32.996µs
          b-pair-rev:       6.506µs
           b-matches:       5.517µs
      b-pair-version:       1.063µs

  TOTAL: 46.494903516s

Writing out github.com/davecgh/go-spew@v1.1.0
Writing out github.com/emicklei/go-restful@v2.2.1
Writing out github.com/go-openapi/jsonpointer@master
Writing out github.com/gogo/protobuf@v0.4
Writing out k8s.io/client-go@v4.0.0
Writing out github.com/docker/distribution@v2.6.2
Writing out github.com/ugorji/go@master
Writing out github.com/go-openapi/analysis@master
Writing out github.com/go-openapi/errors@master
Writing out github.com/go-openapi/jsonreference@master
Writing out github.com/mailru/easyjson@master
Writing out github.com/asaskevich/govalidator@v6
Writing out gopkg.in/yaml.v2@v2
Writing out github.com/emicklei/go-restful-swagger12@1.0.1
Writing out golang.org/x/net@master
Writing out github.com/mitchellh/mapstructure@master
Writing out github.com/go-openapi/loads@master
Writing out github.com/spf13/pflag@v1.0.0
Writing out github.com/go-openapi/spec@master
Writing out k8s.io/apimachinery@master
Writing out golang.org/x/text@master
Writing out github.com/google/gofuzz@master
Writing out github.com/go-openapi/strfmt@master
Writing out github.com/juju/ratelimit@master
Writing out github.com/ghodss/yaml@v1.0.0
Writing out gopkg.in/inf.v0@v0.9.0
Writing out github.com/PuerkitoBio/purell@v1.1.0
Writing out github.com/PuerkitoBio/urlesc@master
Writing out github.com/golang/glog@master
Writing out gopkg.in/mgo.v2@v2
Writing out github.com/go-openapi/swag@master
sttts added a commit to sttts/kube-vendor-test that referenced this issue Aug 30, 2017
@sttts
Copy link
Author

sttts commented Aug 30, 2017

I guess this is answered by https://github.com/golang/dep/blob/master/docs/FAQ.md#how-do-i-constrain-a-transitive-dependencys-version. Still this feels as a very odd design decisions that constraints are only conditional, i.e. if imports are direct.

@sttts sttts closed this as completed Aug 30, 2017
@sdboyer
Copy link
Member

sdboyer commented Aug 30, 2017

yeah, we don't validate this as well as we should - it's what #302 is trying to address.

the reasons for this design are here: https://gist.github.com/sdboyer/b0813bf2b9dba58a335a85092085472f. the limitation to direct dependencies isn't great, but IMO it's the least-bad one of the available options.

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

No branches or pull requests

2 participants