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: poor error message from 'go build -mod=vendor' when passing an absolute package path instead of a relative one #38748

bcmills opened this issue Apr 29, 2020 · 0 comments


Copy link

@bcmills bcmills commented Apr 29, 2020

When foo is a relative subdirectory, the error message from go build foo/ seems a lot worse when -mod=vendor is set than when it is unset:$ go version
go version devel +e1a96b82 Wed Apr 29 08:57:33 2020 +0000 linux/amd64$ go build ./foo$ go build foo/
package foo is not in GOROOT (/usr/local/google/home/bcmills/sdk/gotip/src/foo)$ go build -mod=vendor foo/
package foo: cannot find package "." in:

-- foo/foo.go --
package foo
-- go.mod --

go 1.15

The error message from the first go build foo/ seems reasonable to me: it clearly indicates that foo was interpreted as a package path, where we expected to find that package, and why we failed to do so.

The error message from go build -mod=vendor foo/ is much worse: it mentions a package ".", which has nothing to do with what the user passed in, fails to mention GOROOT (which is where a package named foo generally ought to be) at all, and buries the vendor part in the middle of the file path.

CC @jayconrod @matloob

@bcmills bcmills added this to the Backlog milestone Apr 29, 2020
@bcmills bcmills added the modules label Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.