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: error message refers to "." instead of the path provided on the command line #31031

Closed
pjweinb opened this issue Mar 25, 2019 · 5 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@pjweinb
Copy link

pjweinb commented Mar 25, 2019

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

go version go1.12 linux/amd64

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

linux

What did you do?

go build cmd/gopls

and it says
can't load package: package cmd/gopls: cannot find package "." in:
/usr/lib/google-golang/src/cmd/gopls

Note that . is not mentioned anywhere in the command, nor is there an "import ." anywhere either.

Of course,
go build ./cmd/gopls works,
but the other error message is not helpful.

@bcmills
Copy link
Contributor

bcmills commented Apr 12, 2019

Please complete the issue template.

In particular, we need the go env output to determine whether you are running in module mode or GOPATH mode, since the package-resolution logic differs between the two modes.

@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Apr 12, 2019
@bcmills bcmills changed the title go: build unhelpful error messge cmd/go: error message refers to "." instead of the path provided on the command line Apr 12, 2019
@bcmills
Copy link
Contributor

bcmills commented Apr 12, 2019

CC @jayconrod

@jayconrod jayconrod self-assigned this Apr 15, 2019
@jayconrod jayconrod 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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Apr 16, 2019
@jayconrod
Copy link
Contributor

Reproduced in both modes in Go 1.12.4.

However, the error message is different at tip.

$ GO111MODULE=on go build cmd/gopls
can't load package: package cmd/gopls: unknown import path "cmd/gopls": cannot find module providing package cmd/gopls
$ GO111MODULE=off go build cmd/gopls
can't load package: package cmd/gopls: cannot find package "cmd/gopls" in any of:
	/Users/jayconrod/Code/go/src/cmd/gopls (from $GOROOT)
	/Users/jayconrod/go/src/cmd/gopls (from $GOPATH)

I think the GOPATH message is fine, but the module error message could be improved.

@jayconrod jayconrod added this to the Go1.13 milestone Apr 16, 2019
@bcmills
Copy link
Contributor

bcmills commented May 31, 2019

It's actually even worse now. 😞

example.com$ gotip version
go version devel +2165452a Fri May 31 11:26:23 2019 +0000 linux/amd64

example.com$ gotip mod init example.com
go: creating new go.mod: module example.com

example.com$ gotip build cmd/gopls
can't load package: package cmd/gopls: unknown import path "cmd/gopls": explicit requirement on standard-library module cmd not allowed

example.com$

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

Change https://golang.org/cl/189157 mentions this issue: cmd/go: improve error message for missing import starting with cmd/

@golang golang locked and limited conversation to collaborators Aug 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants