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

Commit 46f64fa

Browse files
committed
Attempt to better explain why -update doesn't work for transitive deps
1 parent 15de9b0 commit 46f64fa

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

FAQ.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Summarize the question and quote the reply, linking back to the original comment
1010
* [Should I commit my vendor directory?](#should-i-commit-my-vendor-directory)
1111
* [Why is it `dep ensure` instead of `dep install`?](#why-is-it-dep-ensure-instead-of-dep-install)
1212
* [Does `dep` replace `go get`?](#does-dep-replace-go-get)
13-
* [Why did `dep ensure -update` not update package X?](#why-did-dep-ensure--update-not-update-package-x)
1413
* [Why is `dep` ignoring the version specified in the manifest?](#why-is-dep-ignoring-the-version-specified-in-the-manifest)
14+
* [Why did `dep ensure -update` not update package X?](#why-did-dep-ensure--update-not-update-package-x)
1515
* [`dep` deleted my files in the vendor directory!](#dep-deleted-my-files-in-the-vendor-directory)
1616
* [Can I put the manifest and lock in the vendor directory?](#can-i-put-the-manifest-and-lock-in-the-vendor-directory)
1717
* [Why did dep use a different revision for package X instead of the revision in the lock file?](#why-did-dep-use-a-different-revision-for-package-x-instead-of-the-revision-in-the-lock-file)
@@ -55,41 +55,41 @@ Here are some suggestions for when you could use `dep` or `go get`:
5555
> is for people consuming Go code, and dep-family commands are for people developing it.
5656
-[@sdboyer in #376](https://github.com/golang/dep/issues/376#issuecomment-294045873)
5757

58-
## Why did `dep ensure -update` not update package X?
59-
Is package X a direct dependency? [#385](https://github.com/golang/dep/issues/385)
60-
61-
Constraints given in a project's manifest are only applied if the
62-
dependent project is actually imported. Transitive dependencies (dependencies
63-
of your imports) are only updated when the revision in the lockfile no
64-
longer meets the constraints of your direct dependencies.
65-
66-
> If you absolutely need to specify the constraint of a transitive dep from your own project, you have two options:
67-
>
68-
> Specify the constraint on github.com/gorilla/context via an override. Overrides apply globally, but are a power only given to the root project, so if anything else imports your project, the override won't be used.
69-
> Mark github.com/gorilla/context as a required package in the manifest. This will cause it to be treated as a direct dependency, and your constraint will come into effect.
70-
>
71-
> However, before taking either of those steps, I'd say it's worth asking if you actually need to use master of github.com/gorilla/context. I imagine it's imported by github.com/gorilla/mux - and if that package is OK with using the tagged release instead of master (which is the preferred mode of operation anyway), then maybe that should be good enough for you? If you really needed something out of github.com/gorilla/context, then you'd probably be importing it directly and doing something with it
72-
-[@sdboyer in #385](https://github.com/golang/dep/issues/385#issuecomment-294361087)
73-
7458
## Why is `dep` ignoring the version specified in the manifest?
7559
Only direct dependencies can be managed with a `dependencies` entry
7660
in the manifest. Use an `overrides` entry for transitive dependencies.
7761

78-
> Constraints:
62+
> Dependencies:
7963
>
8064
> 1. Can be declared by any project's manifest, yours or a dependency
8165
> 2. Apply only to direct dependencies of the project declaring the constraint
82-
> 3. Must not conflict with the constraints declared in any other project's manifest
66+
> 3. Must not conflict with the `dependencies` declared in any other project's manifest
8367
>
8468
> Overrides:
8569
>
8670
> 1. Are only utilized from the current/your project's manifest
8771
> 2. Apply globally, to direct and transitive dependencies
88-
> 3. Supercede constraints declared in all manifests, yours or a dependency's
72+
> 3. Supersede constraints declared in all manifests, yours or a dependency's
8973
>
9074
> Overrides are also discussed with some visuals in [the gps docs](https://github.com/sdboyer/gps/wiki/gps-for-Implementors#overrides).
9175
-[@sdboyer in #328](https://github.com/golang/dep/issues/328#issuecomment-286631961)
9276

77+
78+
## Why did `dep ensure -update` not update package X?
79+
This is a symptom of the same problem in [Why is `dep` ignoring the version specified in the manifest?](#why-is-dep-ignoring-the-version-specified-in-the-manifest) and can occur after you had previously added a `dependencies` entry to your manifest for a [transitive dependency](#what-is-a-direct-or-transitive-dependency) and run `dep ensure`. Later when you attempt to update, project X is not updated as expected.
80+
81+
If you accidentally use a `dependencies` entry for a transitive dependency, **it is silently ignored**. We have #302 open to detect and print a warning when this occurs.
82+
83+
Only direct dependencies can be constrained with a `dependencies` entry, anything else should use a `required` or `overrides` entry.
84+
85+
> If you absolutely need to specify the constraint of a transitive dep from your own project, you have two options:
86+
>
87+
> 1. Specify the constraint on `github.com/gorilla/context` via an override. Overrides apply globally, but are a power only given to the root project, so if anything else imports your project, the override won't be used.
88+
> 2. Mark `github.com/gorilla/context` as a required package in the manifest. This will cause it to be treated as a direct dependency, and your constraint will come into effect.
89+
>
90+
> However, before taking either of those steps, I'd say it's worth asking if you actually need to use `master` of `github.com/gorilla/context`. I imagine it's imported by `github.com/gorilla/mux` - and if that package is OK with using the tagged release instead of `master` (which is the preferred mode of operation anyway), then maybe that should be good enough for you? If you really needed something out of `github.com/gorilla/context`, then you'd probably be importing it directly and doing something with it
91+
-[@sdboyer in #385](https://github.com/golang/dep/issues/385#issuecomment-294361087)
92+
9393
## `dep` deleted my files in the vendor directory!
9494
First, sorry! 😞 We hope you were able to recover your files...
9595

0 commit comments

Comments
 (0)