Skip to content
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 mod download $(go list -m)' fails silently #28338

Closed
JohnTitor opened this issue Oct 23, 2018 · 8 comments
Closed

cmd/go: 'go mod download $(go list -m)' fails silently #28338

JohnTitor opened this issue Oct 23, 2018 · 8 comments
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@JohnTitor
Copy link
Contributor

What version of Go are you using (go version)?

go1.11 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

Windows 10, amd64

What did you do?

go mod download doesn't work well when go mod init without version.
(If you run go mod download something.com/something@latest, doesn't work well too.)

What did you expect to see?

Display message (e.g. go mod init: must be set version)

What did you see instead?

Nothing.
Displaying no message isn't user-friendly I think.

@bcmills
Copy link
Contributor

bcmills commented Oct 23, 2018

when go mod init without version.

What do you mean? go mod init does not normally accept a version.

Please post a complete trace of the commands that you ran and the output they produced.

@bcmills bcmills added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Oct 23, 2018
@bcmills bcmills added this to the Go1.12 milestone Oct 23, 2018
@JohnTitor
Copy link
Contributor Author

JohnTitor commented Oct 23, 2018

Please excuse my poor English.

The command as follow:

  • go mod init github.com/lib/pq
    • run this, cannot download modules even if run go mod download github.com/lib/pq@latest.
  • go mod init github.com/lib/pq@latest
    • run this, can download modules if run go mod download github.com/lib/pq@latest.

(I tested on Windows 10.)

@bcmills bcmills removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 23, 2018
@bcmills
Copy link
Contributor

bcmills commented Nov 14, 2018

  • go mod init github.com/lib/pq
    • run this, cannot download modules even if run go mod download github.com/lib/pq@latest.

That may be a bug, but it's a very strange sequence of commands to run.

  • go mod init github.com/lib/pq tells the go command, “this module contains the source code for github.com/lib/pq”.
  • go mod download github.com/lib/pq@latest tells it “download the latest source code for github.com/lib/pq”.

Since the module itself (by its own definition) contains the source code you requested, in some sense go mod download has no work left to do.

  • go mod init github.com/lib/pq@latest

If that command works at all, that's arguably a bug: the @latest is normally a version specification, not part of the module path, but go mod init takes only a module path.

I'll open a separate issue for that.

@bcmills bcmills changed the title cmd/go: go mod download doesn't work well when go mod init without version cmd/go: 'go mod download $(go list -m)' fails silently Nov 14, 2018
@bcmills
Copy link
Contributor

bcmills commented Nov 14, 2018

The lack of a useful error message is closely related to #27783.

@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Nov 14, 2018
@bcmills bcmills modified the milestones: Go1.12, Go1.13 Nov 14, 2018
@iwdgo
Copy link
Contributor

iwdgo commented May 4, 2019

Issue seems solved

$GOPATH\src\mymod>go version
go version go1.12.2 windows/amd64

$GOPATH\src\mymod>go mod init github.com/lib/pq@latest
go mod init: module path must not contain '@'

@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@bcmills
Copy link
Contributor

bcmills commented Aug 6, 2019

@iwdgo, we could still use a better diagnostic for go mod download with the name of the main module and @latest. It should either download the latest upstream version, or emit some kind of useful diagnostic; today it still does neither:

pq$ gotip mod init github.com/lib/pq
go: creating new go.mod: module github.com/lib/pq

pq$ gotip version
go version devel +a4c82515 Mon Aug 5 23:12:39 2019 +0000 linux/amd64

pq$ gotip mod download github.com/lib/pq@latest

pq$ find $GOPATH/pkg/mod
/tmp/tmp.doY4ctA1kP/_gopath/pkg/mod
/tmp/tmp.doY4ctA1kP/_gopath/pkg/mod/cache
/tmp/tmp.doY4ctA1kP/_gopath/pkg/mod/cache/lock

@gopherbot
Copy link

Change https://golang.org/cl/189797 mentions this issue: cmd/go: print error messages of go mod download without json flag

@iwdgo
Copy link
Contributor

iwdgo commented Aug 18, 2019

Following other merges, the CL is updated. go mod download would return an error when the main module path (as per go.mod) is passed as argument. Without arguments, go mod download will do nothing if go.mod does not contain any dependency. This seems in line with the overall plan in #26152.

(edited)

@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@smasher164 smasher164 modified the milestones: Backlog, Go1.14 Oct 11, 2019
@golang golang locked and limited conversation to collaborators Nov 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

7 participants