Google-cloud-go: Unknown import path cloud.google.com/compute/metadata when using go modules

Created on 15 Nov 2018  路  6Comments  路  Source: googleapis/google-cloud-go

Describe Your Environment

Ubuntu 18.04.1
Go version go1.11 linux/amd64

Expected Behavior

When I run go build, the required packages are downloaded and my binary is compiled.

Actual Behavior

Compilation fails due to an error importing cloud.google.com/go/compute/metadata

go: finding cloud.google.com/go/compute/metadata latest
go: finding cloud.google.com/go/compute latest
../../go/pkg/mod/golang.org/x/[email protected]/google/default.go:16:2: unknown import path "cloud.google.com/go/compute/metadata": cannot find module providing package cloud.google.com/go/compute/metadata

Output of go get -v cloud.google.com/go/compute/metadata

Fetching https://cloud.google.com/go/compute/metadata?go-get=1
Parsing meta tags from https://cloud.google.com/go/compute/metadata?go-get=1 (status code 200)
get "cloud.google.com/go/compute/metadata": found meta tag get.metaImport{Prefix:"cloud.google.com/go", VCS:"git", RepoRoot:"https://code.googlesource.com/gocloud"} at https://cloud.google.com/go/compute/metadata?go-get=1
get "cloud.google.com/go/compute/metadata": verifying non-authoritative meta tag
Fetching https://cloud.google.com/go?go-get=1
Parsing meta tags from https://cloud.google.com/go?go-get=1 (status code 200)
go: finding cloud.google.com/go/compute/metadata latest
Fetching https://cloud.google.com/go/compute?go-get=1
Parsing meta tags from https://cloud.google.com/go/compute?go-get=1 (status code 200)
get "cloud.google.com/go/compute": found meta tag get.metaImport{Prefix:"cloud.google.com/go", VCS:"git", RepoRoot:"https://code.googlesource.com/gocloud"} at https://cloud.google.com/go/compute?go-get=1
get "cloud.google.com/go/compute": verifying non-authoritative meta tag
go: finding cloud.google.com/go/compute latest
Fetching https://cloud.google.com/go?go-get=1
Parsing meta tags from https://cloud.google.com/go?go-get=1 (status code 200)
get "cloud.google.com/go": found meta tag get.metaImport{Prefix:"cloud.google.com/go", VCS:"git", RepoRoot:"https://code.googlesource.com/gocloud"} at https://cloud.google.com/go?go-get=1
Fetching https://cloud.google.com?go-get=1
Parsing meta tags from https://cloud.google.com?go-get=1 (status code 200)
go get cloud.google.com/go/compute/metadata: no matching versions for query "latest"

Output of go build -v

    Fetching https://cloud.google.com/go/compute/metadata?go-get=1
    Parsing meta tags from https://cloud.google.com/go/compute/metadata?go-get=1 (status code 200)
    get "cloud.google.com/go/compute/metadata": found meta tag get.metaImport{Prefix:"cloud.google.com/go", VCS:"git", RepoRoot:"https://code.googlesource.com/gocloud"} at https://cloud.google.com/go/compute/metadata?go-get=1
    get "cloud.google.com/go/compute/metadata": verifying non-authoritative meta tag
    Fetching https://cloud.google.com/go?go-get=1
    Parsing meta tags from https://cloud.google.com/go?go-get=1 (status code 200)
    go: finding cloud.google.com/go/compute/metadata latest
    Fetching https://cloud.google.com/go/compute?go-get=1
    Parsing meta tags from https://cloud.google.com/go/compute?go-get=1 (status code 200)
    get "cloud.google.com/go/compute": found meta tag get.metaImport{Prefix:"cloud.google.com/go", VCS:"git", RepoRoot:"https://code.googlesource.com/gocloud"} at https://cloud.google.com/go/compute?go-get=1
    get "cloud.google.com/go/compute": verifying non-authoritative meta tag
    go: finding cloud.google.com/go/compute latest
    Fetching https://cloud.google.com/go?go-get=1
    Parsing meta tags from https://cloud.google.com/go?go-get=1 (status code 200)
    get "cloud.google.com/go": found meta tag get.metaImport{Prefix:"cloud.google.com/go", VCS:"git", RepoRoot:"https://code.googlesource.com/gocloud"} at https://cloud.google.com/go?go-get=1
    Fetching https://cloud.google.com?go-get=1
    Parsing meta tags from https://cloud.google.com?go-get=1 (status code 200)
    ../../go/pkg/mod/golang.org/x/[email protected]/google/default.go:16:2: unknown import path "cloud.google.com/go/compute/metadata": cannot find module providing package cloud.google.com/go/compute/metadata
p1 bug

Most helpful comment

Thanks for filing this. We recently removed an incorrectly-added module. I had hoped that since we didn't tag that, it would go unnoticed. Unfortunately that does not seem the case - I think we have to do a new release.

In the meantime, you can add require cloud.google.com/go v0.32.0 to your go.mod to get around this issue (in v0.32.0, there was no go.mod yet).

All 6 comments

This is also happening on 1.11.2. I've also added the output of different commands as they have varying errors

Thanks for filing this. We recently removed an incorrectly-added module. I had hoped that since we didn't tag that, it would go unnoticed. Unfortunately that does not seem the case - I think we have to do a new release.

In the meantime, you can add require cloud.google.com/go v0.32.0 to your go.mod to get around this issue (in v0.32.0, there was no go.mod yet).

Downgrading to v0.32.0 has fixed this issue for me. Thanks for the quick response

This should now be fixed - if you depend on oauth2, it should pull in v0.33.1 of cloud.google.com/go, which contains the removal of the go.mod. v0.33.0 will be marked unsafe. Sorry again for breaking you!

my error log is

../../../.gvm/pkgsets/go1.11.2/global/pkg/mod/golang.org/x/[email protected]/google/default.go:17:2: unknown import path "cloud.google.com/go/compute/metadata": ambiguous import: found cloud.google.com/go/compute/metadata in multiple modules:
    cloud.google.com/go v0.33.1 (~/.gvm/pkgsets/go1.11.2/global/pkg/mod/cloud.google.com/[email protected]/compute/metadata)
    cloud.google.com/go/compute/metadata v0.0.0-20181114215827-b51c7c77b284 (~/.gvm/pkgsets/go1.11.2/global/pkg/mod/cloud.google.com/go/compute/[email protected])

I still can not to solve this error in my project.

my go version is : go version go1.11.2 darwin/amd64

Thanks for filing this. We recently removed an incorrectly-added module. I had hoped that since we didn't tag that, it would go unnoticed. Unfortunately that does not seem the case - I think we have to do a new release.

In the meantime, you can add require cloud.google.com/go v0.32.0 to your go.mod to get around this issue (in v0.32.0, there was no go.mod yet).

this one works for me btw. 鉂わ笍

Was this page helpful?
0 / 5 - 0 ratings