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

Created on 20 Aug 2018  路  7Comments  路  Source: golang/go

Related Issue: https://github.com/prometheus/client_golang/issues/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
FrozenDueToAge modules

Most helpful comment

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!

All 7 comments

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.

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

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.

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"

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?

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

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!

Was this page helpful?
0 / 5 - 0 ratings