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: improve error message when a package does not exist #30723

Closed
perillo opened this issue Mar 11, 2019 · 6 comments
Closed

cmd/go: improve error message when a package does not exist #30723

perillo opened this issue Mar 11, 2019 · 6 comments
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@perillo
Copy link
Contributor

perillo commented Mar 11, 2019

What did you do?

In a simple Go program I have a misspelled package import.
As an example

package main

import "logz"

What did you expect to see?

The go tool should report an error message with the file, line and column where the error occurred.
As an example:

main.go:3:2: cannot find package "logz" in any of:
	/usr/lib/go/src/logz (from $GOROOT)
	/home/manlio/.local/lib/go/src/logz (from $GOPATH)
	/home/manlio/code/src/go/src/logz

What did you see instead?

build xxx: cannot load logz: cannot find module providing package logz

There is no additional information; just the module where the problem occurred and the error message.

System details

go version go1.12 linux/amd64
GOARCH="amd64"
GOBIN="/home/manlio/.local/bin"
GOCACHE="/home/manlio/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/manlio/.local/lib/go:/home/manlio/code/src/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/manlio/code/src/python/app/lci/isosmart.it/go.mod"
GOROOT/bin/go version: go version go1.12 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.12
uname -sr: Linux 4.20.13-arch1-1-ARCH
/usr/lib/libc.so.6: GNU C Library (GNU libc) stable release version 2.28.
gdb --version: GNU gdb (GDB) 8.2.1
@perillo
Copy link
Contributor Author

perillo commented Mar 11, 2019

Of course the expected output should be something like:

build xxx: main.go:3:2: cannot load logz: cannot find module providing package logz

Thanks.

@perillo perillo changed the title cmd/go: improve error when a package does not exist cmd/go: improve error message when a package does not exist Mar 11, 2019
@bcmills
Copy link
Contributor

bcmills commented Mar 11, 2019

See also #30661 and #27102.

(CC @jayconrod)

@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. modules labels Mar 11, 2019
@bcmills bcmills added this to the Go1.13 milestone Mar 11, 2019
@jayconrod jayconrod self-assigned this Mar 11, 2019
@manishmshiva
Copy link

Yeah. This looks far better than the original log. I can try and fix this if @jayconrod is busy.

@jayconrod
Copy link
Contributor

@manishmshiva You're welcome to take a look. I'm not sure if I'll get to this for a few days.

This error is reported by the build list loading code in src/cmd/go/internal/modload/load.go. Some additional plumbing will be required to store the import positions.

@bcmills
Copy link
Contributor

bcmills commented Jul 9, 2019

@jayconrod, was this fixed by your import-stack changes?

@jayconrod
Copy link
Contributor

I'm not sure when this was fixed, but the output in go1.13beta1 looks good:

$ go build ./a
b/b.go:3:8: unknown import path "example.com/logz": cannot find module providing package example.com/logz

It's debatable whether cannot find module providing package communicates enough information, but #28459 seems more specific to that. The problem in this issue was that we didn't print the location where the error occurred.

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

No branches or pull requests

6 participants