-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: downgrading a module with go get
retains indirect dependencies
#26481
Comments
In the typical case you can just check out the previous It gets to be more of a problem when you're upgrading and downgrading a bunch of unrelated dependencies in the same change, but that seems easy to avoid: how big is this problem in practice?
|
go get
produces phantom indirect dependenciesgo get
retains indirect dependencies
VCS checkout is great, but it helps only in trivial case when you update, run tests and determine the failure. Then you rollback with VCS and you're done. But imagine more complex situation, when the bug is hidden - either it's not covered with tests properly or it's just too complex and happens in some particular circumstances in runtime. With a panic for example or even some slow goroutine or file descriptor leak. So the gap between updating the go.mod and getting the bug could be hours-days. And even several application releases could happen in this time, with other dependency upgrades possible. Imagine this bug is in production and all you want in this minute is a quick hotfix. You may try to use the VCS, checkout the dependency version from that commit and just take it. So in case of VCS checkout you will have to doublecheck the transitive dependencies in go.mod after And the current behaviour doesn't match with doc from
It doesn't downgrade the other dependencies now actually. PS There is a typo in the docs :) dependenceis -> dependencies |
Rolling back to a previous state is conceptually very different from The |
This is working as designed, as intended, and as documented: go get means make the exact, unique minimum number changes to effect that command, nothing more, nothing less. You are asking for go get to magically infer the "more" you want. That's just not possible. You are asking for version control on go.mod. The go.mod file has been engineered to be version control-friendly, precisely so that job can be reasonably done with your version control system of choice, instead of having the go command reimplement a new version control system of its own. Sorry, I know this is not the answer you want. |
What version of Go are you using (
go version
)?Latest go devel:
go version devel +d278f09333 Thu Jul 19 05:40:37 2018 +0000 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?What did you do?
It's maybe connected with #26474 but is much more severe.
Sorry, can't give you a standalone reproduction again - bug is produced only with downloading updated dependencies.
Consider the following flow:
C(v0.1.0) uses A(v0.1.0):
Then A(v0.2.0) is released and C(v0.2.0) depending on new A(v0.2.0).
We got a project
main
which uses C(v0.1.0) and we want to upgrade C to v0.2.0Output:
All seems OK, than we run tests and understand that C(v0.2.0) is broken -
go test .
We decide to downgrade C back to v0.1.0 used before:
What did you expect to see?
go.mod
should contain downgradedc
dependency onlyWhat did you see instead?
After the downgrade we get unexpected
github.com/mwf/vgo-modules/a v0.2.0 // indirect
and tests still fail.Some thoughts
We should definitely downgrade the transitive dependencies in this case.
But I understand it's a nontrivial task in general - because we should somehow distinguish cases when we intentionally add
a v0.1.1
in main, then upgrade && downgrade c.Ideally, we should go back to
a v0.1.1
andc v.1.0
, but to achieve this we should track the history somehow - and we don't have such feature usinggo.sum
now.cc @myitcv @rsc
The text was updated successfully, but these errors were encountered: