-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: unhelpful "unknown import path" error for 'go build' in an empty module directory #28459
Comments
@vdobler - please can you edit the issue description to follow the full issue template? It makes it much easier to read and digest issues. Thanks |
The fact that
|
That said, we should improve the error message. |
Change https://golang.org/cl/149966 mentions this issue: |
Change https://golang.org/cl/153459 mentions this issue: |
Use the actual loader result in findModule instead of making assumptions about nesting in the build list. As a side-effect, this produces much clearer error messages for packages that (for one reason or another) failed to load. Adjust the package and module path outside a module to "command-line-arguments". That string already appears in the output of a number of (module-mode and GOPATH-mode) commands for file arguments, and as far as I can tell operation outside a module is currently the only case in which the module path of a package is not actually a prefix of the import path. Fixes #28011 Fixes #27099 Fixes #28943 Updates #27102 Updates #28459 Updates #27063 Change-Id: I61d5556df7b1b7d1efdaffa892f0e3e95b612d87 Reviewed-on: https://go-review.googlesource.com/c/153459 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
This issue appears to extend further - build.Import with build.FindOnly should return the directory path resolved for an import, even if there are no Go files in the directory, but this does not seem to be the case with Go modules. |
Change https://golang.org/cl/185343 mentions this issue: |
Change https://golang.org/cl/185345 mentions this issue: |
Change https://golang.org/cl/189780 mentions this issue: |
Updates #30748 Updates #28459 Change-Id: I1c34b3dae0bf9361dba0dae66bb868901ecafe29 Reviewed-on: https://go-review.googlesource.com/c/go/+/189780 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
Change https://golang.org/cl/194817 mentions this issue: |
Jay suggested this in CL 189780, and it seems semantically correct. As far as I can tell this has no impact one way or the other right now, but might prevent confusion (or at least give us more experience with error handling!) in future changes. Updates #30748 Updates #28459 Updates #30322 Change-Id: I5d7e9a08ea141628ed6a8fd03c62d0d3c2edf2bb Reviewed-on: https://go-review.googlesource.com/c/go/+/194817 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
As far as I can tell this is fixed at head.
@vdobler, is this also fixed for your specific example? |
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
…the Target module Updates #28459 Updates #32917 Change-Id: Iced562cb7c2e0ac075d8345f1e4ad3b073842dcf Reviewed-on: https://go-review.googlesource.com/c/go/+/185343 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
This change is a non-minimal fix for #32917, but incidentally fixes several other bugs and makes the error messages much more ergonomic. Updates #32917 Updates #27122 Updates #28459 Updates #29280 Updates #30590 Updates #37214 Updates #36173 Updates #36587 Fixes #36008 Fixes #30992 Change-Id: Iedb26d2e0963697c130df5d0f72e7f83ec2dcf06 Reviewed-on: https://go-review.googlesource.com/c/go/+/185345 Reviewed-by: Michael Matloob <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
What version of Go are you using (
go version
)?go version go1.11.1 darwin/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?At least amd64/darwin and amd64/linux, probably all of them.
What did you do?
If a module is just a wrapper for other packages some commands fail
unexpectedly. They also fail with error messages which are not really
helpful diagnosing the underlying problem.
I set up a module which is just a wrapper around two packages a and b
versioned together:
Doing a
go build ./...
and works fine butgo build
results inOther commands like
go clean -modcache
result in the same error.I think the error can be explained like this:
go build
orgo clean -modcache
are likego build .
orgo clean -modcache .
.
stands for in go.mod yields "path/should/not/matter"(BTW: if the module is e.g. git.intern.ourcorp.net/shared/tooling
the go tool will start querying
Fetching https://git.intern.ourcorp.net/shared?go-get=1
to no avail.)
What did you expect to see?
I would expect that a
GO111MODULE=on go build
fails with the sameerror message like a
GO111MODULE=off go build
in a GOPATH layoutnamely:
To reproduce:
$ cd /tmp
$ mkdir stuff
$ cd stuff/
$ mkdir a b
$ echo -e 'package a\nconst S="Package A"' > a/a.go
$ echo -e 'package b\nconst S="Package B"' > b/b.go
$ go mod init "path/should/not/matter"
go: creating new go.mod: module path/should/not/matter
$ go build ./... # fine
$ go clean -modcache
can't load package: package path/should/not/matter: unknown import path "path/should/not/matter": cannot find module providing package path/should/not/matter
$ go build .
can't load package: package path/should/not/matter: unknown import path "path/should/not/matter": cannot find module providing package path/should/not/matter
The text was updated successfully, but these errors were encountered: