-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: run gives conflicting advice when using path@version syntax #29415
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
Comments
Thank you for this report @davecheney! |
Seems to not be working for me, either:
|
Hit this as well in #29575. Closing that as duplicate. |
Only go get and module-manipulation commands take path@version. |
Go get does not take path@version for me. I've filed #29659, since that appears to be different from the |
Can someone take a look at this please? Example from https://golang.org/cmd/go/#hdr-Module_aware_go_get which is This is breaking go-get’s ability as a package manager as the support for the |
@ahmetb, this issue is about the diagnostic messages. If That said, from the detail in #29575 it appears that you are, in fact, running in
|
@bcmills I'm still seeing this despite I'm not running in GOPATH mode. Here's a minimal repro with go1.12
# unset all env vars, with the exception of $HOME (mock it) and $PATH (inherit it)
env -i HOME="$PWD/mock-home" PATH="$PATH" go build -o ./httpstat github.com/davecheney/httpstat
go: finding github.com/davecheney/httpstat v1.0.0
go: downloading github.com/davecheney/httpstat v1.0.0
go: extracting github.com/davecheney/httpstat v1.0.0
...
(works)
Would you still suggest I'm in " |
@ahmetb, this issue is about the The advice from the commands you posted above does not conflict: it correctly indicates that, in module mode (which you are clearly in), you “can only use path@version syntax with 'go get'”. |
With Go 1.13, also running into
This is so annoying. Especially because it does not tell one what to do. |
From what I can tell, you just have to be in a package that has a go.mod file. Then you can get a particular version. |
Thanks to @smikulcik's comment As someone who doesn't program in |
As I understand it, path@version should be used in Golang specifically for version maintenance. Hence @smikulcik comment to run the command in directory with go.mod file makes sense. Go will try to download the repository to your src folder from Github and will try to maintain the version in the mod file. |
@nivekastoreth FWIW I've written Go for the last five years and this is frustrating for me too. These error messages are not helpful. Users should not need search the Internet for this error message to install an app from a git repository in an expected way. What steps can we take to make this just work and fix this user/developer experience? The answer is not "RTFM" Essays about Go mod version-specific pitfalls and workarounds shouldn't need exist. What can we do? |
Practical example: I want to use Go-jsonnet (https://github.com/google/go-jsonnet), and I need a feature (TOML output) that has been added later than the most recent label in the git repository. The official installation instructions are go get github.com/google/go-jsonnet/cmd/jsonnet which installs the last label. Game over for my TOML files. Plausible workarounds are all ridiculous:
|
Change https://golang.org/cl/282121 mentions this issue: |
What version of Go are you using (
go version
)?% go version
go version devel +97d5cb24b1 Sat Dec 22 09:37:04 2018 +0000 linux/amd64
Does this issue reproduce with the latest release?
unknown
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Go 1.12beta1 (tip) does not permit @Version syntax unless modules explicitly enabled, even if GOPATH is unset
What did you expect to see?
env GO111MODULE=on go run -v github.com/davecheney/httpstat@1.0.0
would download and build httpstat v1.0.0
What did you see instead?
Running without modules enabled tells me I must enable modules even thought I don't have GOPATH set. Running with modules enable tells me I must set GOPATH.
Setting both tells me that this isn't supported.
a. Can
go run path@version
be supported? If not, why not?b. Can the error messages be improved make it clearer sooner that the operation will not succeed once the correct permutation of environment variables is discovered.
The text was updated successfully, but these errors were encountered: