-
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: go get should not add a dependency to go.mod #27643
Comments
From the bottom of
From
|
@natefinch I think the documentation on this covers the points you raise, but please do say if you think it could be better signposted. cc @bcmills |
It's not about the documentation. It's a complete change to what Changing what an established command does, in such an important way, is a really bad idea. I think it's pretty clear, if I Like I said in the bug report... we have a command for dealing with modules. Why would we not just add this functionality there? |
I agree with this. I've already been surprised three separate times now by running Before modules, |
In a GOPATH world I would agree. But we're talking a modules world here. From my perspective I'm fully anticipating any Put another way (and this is where #24250 comes in), I would expect, in a modules world, to have to do something "special" in order to performa a "global" install (by definition outside the context of my |
I was also surprised by this behavior. The suggestion that Regardless of these examples, what bothers me the most is that we're using the same command that has existed for several years to do a different thing. Are we all supposed to accept that every tutorial, every doc, everything that has ever been said about The global place for installing any library or tool still exists, so why do we need to do something special to get back the behavior that already exists? |
Have to chime in that that I agree with @natefinch and @vdemario here. Using We're adding entirely new behavior via the |
Also, apparently trying to install a tool outside a module doesn't even work: /tmp
$ set -gx GO111MODULE on # fish shell syntax
/tmp
$ go get golang.org/x/tools/cmd/goimports
go: cannot find main module; see 'go help modules' |
That issue clarifies this one even more. Prior to Go 1.11, the semantics for And that's a bit of a problem, since |
Then:
This falls under the umbrella of #24250. As @komuw linked above, for discussion on the current "best practice" for defining tool dependencies, please see #25922 |
But it's not about tool dependencies. It's about tools you want to install on a global level, unrelated to the current module. That's the issue at the root of this, that under the Go module framework, |
Indeed, that's why I linked to #24250. Just to emphasise what @rsc said in #24250 (comment):
(we can now substitute So there is agreement that this "global" concept indeed very much has merit. It's just that this didn't make Go 1.11.
Hopefully the link above covers this point? |
Why aren't there |
You are mistaken. The
In my opinion, it is unfortunate that |
This is kind of a hobbyist workflow, I suppose, but most serious Go users are not using OTOH I suspect that many or most Go users make use of the "fetch/update a Go tool" functionality of |
....sure. I'm not sure what that has to do with
There's no reason why it couldn't do the exact same thing in the go modules world. You're explicitly telling the go tool not to build the local directory. I agree that When you give it a package path, though, you're explicitly telling it not to work on the local directory. That's the disconnect. |
I agree that Considering that, why does the module-aware It seems counter-intuitive that a command that already does too much is getting new responsibilities and side effects (such as updating |
But As weird as it is for |
Every command that loads packages updates (We did add one new responsibility to |
I feel like this is a disconnect between people who use a single gopath for everything (i.e. google) and people who exclusively use vendored dependencies. Every serious public project for a long time has used vendored dependencies. |
IMO I'd really prefer if the commands to update dependencies were explicit and obvious named. Why hang on to this fairly vague word "get" when we're talking about actions that never existed before? |
Most Google-internal users pretty much aren't using
Yes, we clearly need to work on the migration path for vendoring. That's one of my top priorities for 1.12. |
I completely agree that That said, maybe it's worth leaving the |
|
Sorry! I almost deleted the google bit there. definitely was not trying to make this a google vs. the outside world. |
I've been using something very similar to install Go binaries from source instead of using |
I support what Russ/Bryan are doing with the #27653 (comment) is a good summary of how that balance is currently struck. None of this precludes experiments in other tools, and https://github.com/myitcv/gobin is one such experiment. It may live on, it may die... any number of outcomes. And most importantly none of this precludes the @leighmcculloch - hopefully the usage docs for |
Those of you who followed this thread might be interested in #30515, to add a "global install" command of some sort. |
Another point of concern here is the unexpected removal of values from go.mod. I am building a WAMP server that utilizes https://github.com/gammazero/nexus, which in turn relies in https://github.com/ugorji/go. ugorji's module is atypical in that there is no code nor mod file in the root of the repo, rather everything is under ugorji pushed a breaking change to their master branch in march 2019. The version nexus pins in its own checked-in vendor dir is from 2018. The ugorji repo does have tagged versions, but it is impossible to actually USE them with go modules, it seems. The code is under The only solution I have found to this extremely idiotic issue is to do the following:
This works as I basically take every version since the last tag (v1.1.2) of the repo and replace it the tagged version. However. When any command dealing with deps is run ( I fully appreciate that I am stupid, am probably doing it wrong, etc., however it is still annoying. I would greatly appreciate a "no cleanup" or "no edit" option or something, so I am not bit by build errors at midnight because I forgot to re-un-edit my program's mod file. |
If you observe otherwise, please file a separate issue with steps to reproduce the error — this issue is closed, and closed issues are not tracked or triaged. |
I need something until golang/go#27643 is fixed.
golint changed its import path [1], and that along with the advent of modules caused fallout [2, 3] that broke the `go get -u` installation in our makefile/CI build. The tools.go idiom is the currently favored approach for versioning development tools with the module system [4, 5], in a way that `go mod tidy` won't churn them from `go.mod` and the `+build` constraint keeps them out of actual build products. The tools still need to be `go install`ed, within a module `go get -u` is not the thing to do anymore because it upgrades transitive deps of a tool which may change the module's build. It takes like hours of reading discussions to triangulate on these moving targets... [5, 6, 7, 8] jfc how much of life have I spent following the fashion evolution of Go dependency management [1]: golang/lint@c363707 [2]: golang/go#30455 [3]: golang/go#30831 [4]: https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module [5]: golang/go#25922 [6]: golang/go#27653 [7]: golang/go#27643 [8]: golang/go#30515
when enable go module, go get will update the required version. It is not supported to run in CI. More info: golang/go#27643. Signed-off-by: Wei Fu <[email protected]>
when enable go module, go get will update the required version. It is not supported to run in CI. More info: golang/go#27643. Signed-off-by: Wei Fu <[email protected]>
go get
is not the right command for adding a dependency to the current module. We have a command for dealing with modules, and it'sgo mod
, that's the command that should be used to add dependencies.This is the first paragraph of help on
go get
:None of that says "add the library you specified to the dependencies of the current project". And why would it? it's for getting code from somewhere else and bringing it to this machine.
Notably,
go get
will even add go commands as a dependency... so like if you rungo get golang.org/x/tools/cmd/goimports
and your current directory happens to be a go module, guess what? Your go.mod now hasThis UX is extremely confusing for the ~2 million people who used go before modules. It's also way too implicit and magic regardless of the experience. Adding a dependency to your project should be an explicit action:
What did you do?
from inside a module directory
What did you expect to see?
No change to my go.mod
What did you see instead?
go get added a library to my go.mod file.
System details
The text was updated successfully, but these errors were encountered: