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: better diagnostics for package missing in latest version #27102

Closed
icholy opened this issue Aug 20, 2018 · 7 comments
Closed

cmd/go: better diagnostics for package missing in latest version #27102

icholy opened this issue Aug 20, 2018 · 7 comments

Comments

@icholy
Copy link

icholy commented Aug 20, 2018

Related Issue: prometheus/client_golang#442

What version of Go are you using (go version)?

go version go1.11rc1 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN="/home/icholy/Code/bin"
GOCACHE="/home/icholy/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/icholy/Code"
GOPROXY=""
GORACE=""
GOROOT="/home/icholy/sdk/go1.11rc1"
GOTMPDIR=""
GOTOOLDIR="/home/icholy/sdk/go1.11rc1/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build529551486=/tmp/go-build -gno-record-gcc-switches"

What did you do?

git clone https://github.com/icholy/prom_thing.git
cd prom_thing
go1.11rc1 build

What did you expect to see?

Success

What did you see instead?

go: finding github.com/prometheus/client_golang/api/prometheus latest
go: finding github.com/prometheus/client_golang/api latest
build prom_thing: cannot find module for path github.com/prometheus/client_golang/api/prometheus/v1
@VojtechVitek
Copy link

github.com/prometheus/client_golang/api/prometheus is not a module, it's a package

I think you need to change

-    github.com/prometheus/client_golang/api/prometheus/v1
+    github.com/prometheus/client_golang/api

in your import statement.

@icholy
Copy link
Author

icholy commented Aug 20, 2018

@VojtechVitek that just imports a different package which I don't need.

@rsc
Copy link
Contributor

rsc commented Aug 21, 2018

The problem is that github.com/prometheus/client_golang/api/prometheus/v1 does not exist in the latest tagged commit of github.com/prometheus/client_golang, which is v0.8.0 and is quite old.

To get the latest commit on the master branch instead of the latest tagged commit, run:

go get github.com/prometheus/client_golang@master

Then your build will work. And maybe encourage the owners of github.com/prometheus/client_golang to tag v0.9.0.

@rsc rsc changed the title cmd/go: cannot import package who's name is v1 cmd/go: better diagnostics for package missing in latest version Aug 21, 2018
@rsc
Copy link
Contributor

rsc commented Aug 21, 2018

Leaving this issue open to track emitting a clearer error message in this case. I'd like to see something along the lines of "github.com/prometheus/client_golang v0.8.0 has no package github.com/prometheus/client_golang/api/prometheus"

@rsc rsc added this to the Go1.12 milestone Aug 21, 2018
@rsc rsc added the modules label Aug 21, 2018
@krasi-georgiev
Copy link

after a short discussion something like v0.9.0-pre.2 would be best for consistency with the other tags in the repo.

Would vgo understand this?

@bcmills bcmills modified the milestones: Go1.12, Go1.13 Oct 25, 2018
@rsc rsc self-assigned this Oct 25, 2018
@rsc rsc modified the milestones: Go1.13, Go1.12 Oct 25, 2018
@bcmills bcmills modified the milestones: Go1.12, Go1.13 Nov 16, 2018
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/153459 mentions this issue: cmd/go: fix 'go test' and 'go fmt' with files outside a module

gopherbot pushed a commit that referenced this issue Dec 11, 2018
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]>
@bcmills bcmills modified the milestones: Go1.13, Go1.12 Dec 12, 2018
@bcmills bcmills assigned bcmills and unassigned rsc Dec 12, 2018
@andybons andybons modified the milestones: Go1.12, Go1.13 Feb 12, 2019
@andybons andybons removed this from the Go1.13 milestone Jul 8, 2019
@andybons andybons added this to the Go1.14 milestone Jul 8, 2019
@bcmills
Copy link
Contributor

bcmills commented Aug 7, 2019

I'd like to see something along the lines of "github.com/prometheus/client_golang v0.8.0 has no package github.com/prometheus/client_golang/api/prometheus"

Using gotip (previewing Go 1.13), I see a very similar message to that now:

example.com$ go get github.com/prometheus/client_golang/api/prometheus/[email protected]
go: finding github.com v0.8.0
go: finding github.com/prometheus/client_golang/api/prometheus v0.8.0
go: finding github.com/prometheus/client_golang/api v0.8.0
go: finding github.com/prometheus/client_golang v0.8.0
go: finding github.com/prometheus v0.8.0
go: downloading github.com/prometheus/client_golang v0.8.0
go: extracting github.com/prometheus/client_golang v0.8.0
go get github.com/prometheus/client_golang/api/prometheus/[email protected]: module github.com/prometheus/[email protected] found, but does not contain package github.com/prometheus/client_golang/api/prometheus/v1

I'm going to call this fixed. If folks run into similar circumstances where the diagnostic could be improved, please file a new issue to let us know!

@bcmills bcmills closed this as completed Aug 7, 2019
@golang golang locked and limited conversation to collaborators Aug 6, 2020
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants