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: include file name in error message for bad import #4223

Closed
gopherbot opened this issue Oct 9, 2012 · 13 comments
Closed

cmd/go: include file name in error message for bad import #4223

gopherbot opened this issue Oct 9, 2012 · 13 comments
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@gopherbot
Copy link
Contributor

by peter.waller:

Mailing list discussion is here:

https://groups.google.com/forum/?fromgroups=#!topic/golang-dev/4oYo21jEGuU

At maximum verbosity, `go get` does not give enough information as to what is causing
the failure if it encounters an invalid import. Ideally, it would always report the
package/file/line number where the invalid import is located. Otherwise it could be
buried somewhere deep in a dependency tree.

Example:

   $ go get -d -v -n github.com/go-gl/...
    import "sdl": import path doesn't contain a slash
    package sdl: unrecognized import path "sdl"

There is something in the code that raises this error talking about the error detail
being irrelevant. I don't understand why.

http://golang.org/src/cmd/go/vcs.go#L322
@minux
Copy link
Member

minux commented Oct 9, 2012

Comment 1:

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 2:

Labels changed: added size-m.

@rsc
Copy link
Contributor

rsc commented Dec 30, 2012

Comment 3:

Labels changed: added priority-later, removed priority-triage.

@rsc
Copy link
Contributor

rsc commented Mar 12, 2013

Comment 4:

Labels changed: added go1.1maybe, removed go1.1.

@robpike
Copy link
Contributor

robpike commented May 18, 2013

Comment 5:

Labels changed: added go1.2maybe, removed go1.1maybe.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 6:

Labels changed: added feature.

@robpike
Copy link
Contributor

robpike commented Sep 3, 2013

Comment 7:

Not in time for 1.2.

Labels changed: removed go1.2maybe.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 8:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 9:

Labels changed: removed feature.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 10:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 11:

Labels changed: added repo-main.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@ysmolski
Copy link
Member

Example in the topic is not reproducible. So I made this:

% go get -d -v -n github.com/ysmolsky/import-error/...
github.com/ysmolsky/import-error (download)
# cd /Users/thorn/go/src/github.com/ysmolsky/import-error; git sync/update
package github.com/ysmolsky/import-error/t1
	imports sdl: unrecognized import path "sdl" (import path does not begin with hostname)

Reported error is somewhat better. It tells the package where problem happened. But it does not tell the file/line.

@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 13, 2024
@seankhliao seankhliao changed the title cmd/go: improve error message when "go get" encounters an unexpected import cmd/go: include file name in error message for bad import Dec 1, 2024
@seankhliao seankhliao added the GoCommand cmd/go label Dec 1, 2024
@matloob
Copy link
Contributor

matloob commented Dec 17, 2024

GOPATH go get is no longer supported. As of Go 1.24, if we try to do a go get that has a bad import, we get the following:

go: example.com/baz imports
	sdl: package sdl is not in std (/Users/matloob/devgo/src/sdl)

This should now be tracked in #41688, which is a newer issue that tracks adding line numbers to the import stacks printed by (*loadPkg).stackText. See specifically Jay's comment #41688 (comment)

@matloob matloob closed this as not planned Won't fix, can't repro, duplicate, stale Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

7 participants