profile
viewpoint

Ask questionscmd/go: "found, but does not contain package" error refers to replaced version instead of its replacement

<!-- Please answer these questions before submitting your issue. Thanks! -->

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

<pre> $ go version go version go1.13 darwin/amd64 </pre>

Does this issue reproduce with the latest release?

Yes

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

<details><summary><code>go env</code> Output</summary><br><pre> $ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/rajagast/Library/Caches/go-build" GOENV="/Users/rajagast/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GONOPROXY="none" GONOSUMDB="git.company.com" GOOS="darwin" GOPATH="/Users/rajagast/go" GOPRIVATE="git.company.com" GOPROXY="https://athens.company.com" GOROOT="/usr/local/Cellar/go/1.13/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.13/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/rajagast/go/src/git.company.com/CPSG/ccp-operator/go.mod" 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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/d0/18x8fk8571v3t2p12n8r340h0000gn/T/go-build223406614=/tmp/go-build -gno-record-gcc-switches -fno-common" </pre></details>

What did you do?

I have k8s.io/code-generator as a tools dependency i.e. I have a top-level tools.go file with these contents:

// +build tools

package tools

import (
	_ "k8s.io/code-generator/cmd/client-gen"
	_ "k8s.io/code-generator/cmd/conversion-gen"
	_ "k8s.io/code-generator/cmd/deepcopy-gen"
	_ "k8s.io/code-generator/cmd/defaulter-gen"
	_ "k8s.io/code-generator/cmd/informer-gen"
	_ "k8s.io/code-generator/cmd/lister-gen"
	_ "k8s.io/code-generator/cmd/openapi-gen"
)

I also have one private dependency, so according to go1.13 I'm setting appropriate env variables.

$ go env -w GOPRIVATE=git.company.com GOPROXY=https://athens.company.com GONOPROXY=none

When I do go mod tidy, I get the following failure which is very vague:

go: finding k8s.io/code-generator latest
git.company.com/CPSG/ccp-operator imports
	k8s.io/code-generator/cmd/openapi-gen: module k8s.io/code-generator/cmd/openapi-gen: reading https://athens.company.com/k8s.io/code-generator/cmd/openapi-gen/@v/list: 500 Internal Server Error
git.company.com/CPSG/ccp-operator/pkg/controller/cluster/worker imports
	github.com/openshift/kubernetes-drain tested by
	github.com/openshift/kubernetes-drain.test imports
	github.com/go-log/log/capture: module github.com/go-log/log/capture: reading https://athens.company.com/github.com/go-log/log/capture/@v/list: 500 Internal Server Error

The interesting thing is when I turn off GOPROXY with go env -w "GOPROXY=", it shows a different error:

go: finding k8s.io/code-generator latest
git.company.com/CPSG/ccp-operator imports
	k8s.io/code-generator/cmd/openapi-gen: module k8s.io/code-generator@latest (v0.0.0-20190831074504-732c9ca86353) found, but does not contain package k8s.io/code-generator/cmd/openapi-gen
git.company.com/CPSG/ccp-operator/pkg/controller/cluster/worker imports
	github.com/openshift/kubernetes-drain tested by
	github.com/openshift/kubernetes-drain.test imports
	github.com/go-log/log/capture: module github.com/go-log/log@latest (v0.1.0) found, but does not contain package github.com/go-log/log/capture

The error k8s.io/code-generator/cmd/openapi-gen: module k8s.io/code-generator@latest (v0.0.0-20190831074504-732c9ca86353) found, but does not contain package k8s.io/code-generator/cmd/openapi-gen is strange because latest code in that repo does contain that package.

Fwiw, this used to work perfectly fine with go1.12.9 yesterday.

This is my go.mod:

module git.company.com/CPSG/ccp-operator

go 1.12

require (
	github.com/docker/distribution v2.7.1+incompatible // indirect
	github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect
	github.com/elazarl/goproxy v0.0.0-20181111060418-2ce16c963a8a // indirect
	github.com/evanphx/json-patch v4.2.0+incompatible // indirect
	github.com/ghodss/yaml v1.0.0 // indirect
	github.com/go-log/log v0.1.0 // indirect
	github.com/go-logr/logr v0.1.0
	github.com/go-logr/zapr v0.1.0
	github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d // indirect
	github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
	github.com/golang/groupcache v0.0.0-20180924190550-6f2cf27854a4 // indirect
	github.com/google/btree v1.0.0 // indirect
	github.com/google/uuid v1.1.1
	github.com/googleapis/gnostic v0.2.0 // indirect
	github.com/gorilla/mux v1.7.1
	github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
	github.com/hashicorp/golang-lru v0.5.1 // indirect
	github.com/imdario/mergo v0.3.6 // indirect
	github.com/json-iterator/go v1.1.7 // indirect
	github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a // indirect
	github.com/modern-go/reflect2 v1.0.1 // indirect
	github.com/onsi/ginkgo v1.8.0
	github.com/onsi/gomega v1.5.0
	github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
	github.com/openshift/cluster-network-operator v0.0.0-20190613202004-28fc1e342cde // indirect
	github.com/openshift/kubernetes-drain v0.0.0-20180831174519-c2e51be1758e
	github.com/operator-framework/operator-sdk v0.4.1
	github.com/pborman/uuid v1.2.0
	github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
	github.com/pkg/errors v0.8.1
	github.com/prometheus/client_golang v0.9.2 // indirect
	github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 // indirect
	github.com/prometheus/common v0.2.0 // indirect
	github.com/prometheus/procfs v0.0.0-20190403104016-ea9eea638872 // indirect
	github.com/renstrom/dedent v0.0.0-00010101000000-000000000000 // indirect
	github.com/rogpeppe/go-internal v1.3.0 // indirect
	github.com/spf13/pflag v1.0.3 // indirect
	github.com/vmware/govmomi v0.19.0
	go.uber.org/atomic v1.3.2 // indirect
	go.uber.org/multierr v1.1.0 // indirect
	go.uber.org/zap v1.9.1
	golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 // indirect
	golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc
	golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a // indirect
	golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f // indirect
	golang.org/x/text v0.3.2 // indirect
	golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 // indirect
	golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac // indirect
	google.golang.org/appengine v1.5.0 // indirect
	gopkg.in/inf.v0 v0.9.1 // indirect
	gopkg.in/yaml.v2 v2.2.2 // indirect
	k8s.io/api v0.0.0-20190704094930-781da4e7b28a
	k8s.io/apiextensions-apiserver v0.0.0-20190704104408-4c62af35d786
	k8s.io/apimachinery v0.0.0-20190704094625-facf06a8f4b8
	k8s.io/apiserver v0.0.0-20190704101201-5341ddeccec6 // indirect
	k8s.io/client-go v10.0.0+incompatible
	k8s.io/cluster-bootstrap v0.0.0-20190704110328-86aca54c9e62
	k8s.io/code-generator v0.0.0-20190704094322-1ed9df051d9b
	k8s.io/gengo v0.0.0-20190826232639-a874a240740c // indirect
	k8s.io/klog v0.4.0 // indirect
	k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf // indirect
	k8s.io/kube-proxy v0.0.0-20190704105642-5b7f4f839816 // indirect
	k8s.io/kubelet v0.0.0-20190704105832-d6717358a5ca // indirect
	k8s.io/kubernetes v1.13.5
	k8s.io/utils v0.0.0-20190607212802-c55fbcfc754a // indirect
	sigs.k8s.io/controller-runtime v0.1.9
	sigs.k8s.io/testing_frameworks v0.1.1 // indirect
	git.company.com/CPSG/ccp-net-tinker v0.0.2-0.20190614085909-34571ec5f0c5
)

replace (
	github.com/renstrom/dedent => github.com/lithammer/dedent v1.1.0
	k8s.io/code-generator => k8s.io/code-generator v0.0.0-20190704094322-1ed9df051d9b
)

What did you expect to see?

go mod tidy resolve dependencies correctly without error, as it did with go1.12.9.

What did you see instead?

Two issues:

  1. go mod tidy says packages do not exist when they are indeed present.
  2. When GOPROXY is set, it errors out without any meaningful message.
golang/go

Answer questions heschik

github.com/go-log/log/capture: module github.com/go-log/log/capture: reading https://athens.company.com/github.com/go-log/log/capture/@v/list: 500 Internal Server Error

For this you'll have to check out your Athens instance, no idea what the problem is there.

For the second part, I can reproduce with

git clone https://github.com/openshift/kubernetes-drain.git
cd kubernetes-drain
go mod init github.com/openshift/kubernetes-drain
go test -c

Let me see what I can figure out...

useful!

Related questions

cmd/link: segmentation fault during mach-o linking hot 4
cmd/go: cannot find module providing package error stops `go get` processing hot 2
cmd/go: needs a better error than "missing dot in first path element" when GOROOT is set incorrectly hot 2
x/xerrors: fails to compile on tip hot 1
vendor/golang.org/x/xerrors/adaptor_go1_13.go:16:14: undefined: errors.Frame ... hot 1
cmd/go: `go clean <package>` downloads modules hot 1
cmd/cgo error: runtime: unknown pc 0x7fff5c805b86 hot 1
runtime: crash with "invalid pc-encoded table" hot 1
cmd/vet: potential false positive in the "suspect or" check hot 1
cmd/link: showing many ld warnings of "building for macOS, but linking in object file" hot 1
runtime: go program crach, it seems fall into infinite loop hot 1
cmd/go: major version without preceding tag must be v0, not v1 - breaks build of github.com/go-check hot 1
runtime: macOS Sierra builders spinning hot 1
cmd/go: Problem using go modules hot 1
cmd/go: "unrecognized import path" for local packages after updating to go1.13 hot 1
Github User Rank List