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

Comments

@JohnTitor
Copy link
Contributor

@JohnTitor JohnTitor commented Oct 23, 2018

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

This comment has been minimized.

Copy link
Member

@bcmills 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.

@JohnTitor

This comment has been minimized.

Copy link
Contributor Author

@JohnTitor 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 label Oct 23, 2018
@bcmills

This comment has been minimized.

Copy link
Member

@bcmills 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

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Nov 14, 2018

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

@bcmills bcmills added NeedsFix and removed NeedsInvestigation labels Nov 14, 2018
@bcmills bcmills modified the milestones: Go1.12, Go1.13 Nov 14, 2018
@iWdGo

This comment has been minimized.

Copy link
Contributor

@iWdGo 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

This comment has been minimized.

Copy link
Member

@bcmills 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

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Aug 10, 2019

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

@iWdGo

This comment has been minimized.

Copy link
Contributor

@iWdGo 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
@gopherbot gopherbot closed this in 696c414 Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.