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

Comments

@pjweinb
Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member

commented Apr 12, 2019

@jayconrod

This comment has been minimized.

Copy link
Contributor

commented Apr 16, 2019

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link

commented Aug 6, 2019

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

@gopherbot gopherbot closed this in e37a1b1 Aug 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.