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

replace directive in parent causes, error loading module requirements #29376

Closed
komuw opened this issue Dec 21, 2018 · 7 comments
Closed

replace directive in parent causes, error loading module requirements #29376

komuw opened this issue Dec 21, 2018 · 7 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@komuw
Copy link
Contributor

komuw commented Dec 21, 2018

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

$ go version
go version go1.12beta1 darwin/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/me/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/me/go"
GOPROXY=""
GORACE=""
GOROOT="/Users/me/sdk/go1.12beta1"
GOTMPDIR=""
GOTOOLDIR="/Users/me/sdk/go1.12beta1/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/me/Downloads/stuff/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/p5/56z0g6pj6dq0njc1n6wccz4r0000gn/T/go-build591275965=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

create this main.go file;

package main

import (
    "fmt"
    "github.com/perlin-network/life/exec"
)

func main() {
    fmt.Println(exec.DefaultCallStackSize)
}

and ran;
go1.12beta1 run main.go

What did you expect to see?

success or a helpful error message

What did you see instead?

go1.12beta1 run main.go
go: finding github.com/perlin-network/life/exec latest
go: finding github.com/perlin-network/life latest
go: finding github.com/go-interpreter/wagon v0.0.0
go: github.com/go-interpreter/[email protected]: unknown revision v0.0.0
go: error loading module requirements
@komuw
Copy link
Contributor Author

komuw commented Dec 21, 2018

commentary:

The module github.com/perlin-network/life has a replace directive in it's go.mod file:
https://github.com/perlin-network/life/blob/28a99a6d79ec86732bd0eca66fe45c88f7f29bbc/go.mod#L3
that directive is ignored leading to this failure.

unfortunately, the error message doesn't point out that it is as a result of an ignored replace directive in the parent module(github.com/perlin-network/life) and thus making it hard to diagnose what is going on.

@komuw
Copy link
Contributor Author

komuw commented Dec 21, 2018

Another reproduction;

package main

import (
	"log"
	"github.com/komuw/meli"
)

func main() {
	auth := meli.AuthInfo
	log.Println(auth)
}

go1.12beta1 run main.go

# github.com/komuw/meli
../../go/pkg/mod/github.com/komuw/[email protected]/types.go:77:44: undefined: volume.VolumeCreateBody
../../go/pkg/mod/github.com/komuw/[email protected]/types.go:120:70: undefined: volume.VolumeCreateBody
../../go/pkg/mod/github.com/komuw/[email protected]/volume.go:16:3: undefined: volume.VolumeCreateBody

thee parent module github.com/komuw/meli has replacement; https://github.com/komuw/meli/blob/master/go.mod#L47-L53 that get ignored

@komuw
Copy link
Contributor Author

komuw commented Dec 21, 2018

@gopherbot, please add label modules

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 21, 2018
@bcmills
Copy link
Contributor

bcmills commented Dec 21, 2018

The error message here describes exactly the problem: go: github.com/go-interpreter/[email protected]: unknown revision v0.0.0. There is, indeed, no such version tagged in the repository, and (by design) replacements have no effect unless the module containing the replace directive is the main module.

We should not point out that it is the result of an ignored replace directive, because replace directives from other modules are always ignored. The problem is the invalid version in the require directive, and it would exist even without the corresponding replace.

Arguably go mod tidy within github.com/perlin-network/life should either choose a valid version or report an error; it does not today, and that's #29182.

@bcmills
Copy link
Contributor

bcmills commented Dec 21, 2018

The situation in github.com/komuw/meli is worse, because the module owner is specifying incompatible versions: the require section declares a dependency on github.com/docker/distribution v2.6.2+incompatible, but the replace section selects what appears to be a semantically older version (v2.6.0-rc.1.0.20180820212402-02bf4a2887a4+incompatible).

If that commit really is newer than v2.6.2, then it should have a newer pseudo-version. In fact, that commit seems to have been tagged v2.7.0, which gives you an upgrade path to fix the problem. The solution with docker/docker is similar: explicitly go get the master version rather than the latest semantic tag.

$ go mod init golang.org/issue/scratch
go: creating new go.mod: module golang.org/issue/scratch

$ cat > main.go
package main

import (
        "log"
        "github.com/komuw/meli"
)

func main() {
        auth := meli.AuthInfo
        log.Println(auth)
}

$ go get -m github.com/docker/[email protected] github.com/docker/docker@master
go: finding github.com/docker/docker master
go: finding github.com/docker/distribution v2.7.0+incompatible

$ go mod tidy
go: finding github.com/komuw/meli v0.2.1
go: downloading github.com/komuw/meli v0.2.1
go: extracting github.com/komuw/meli v0.2.1
go: finding github.com/docker/docker v0.0.0-20170601211448-f5ec1e2936dc
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding github.com/onsi/gomega v1.4.1
go: finding github.com/gorilla/context v1.1.1
go: finding github.com/docker/go-connections v0.4.0
go: finding github.com/golang/protobuf v1.2.0
go: finding github.com/fsnotify/fsnotify v1.4.7
go: finding golang.org/x/sys v0.0.0-20180821044426-4ea2f632f6e9
go: finding golang.org/x/text v0.3.0
go: finding golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
go: finding golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2
go: finding github.com/gorilla/mux v1.6.2
go: finding github.com/kr/pretty v0.1.0
go: finding github.com/Microsoft/go-winio v0.4.10
go: finding github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
go: finding gotest.tools v2.1.0+incompatible
go: finding google.golang.org/grpc v1.14.0
go: finding github.com/gogo/protobuf v1.1.1
go: finding golang.org/x/net v0.0.0-20180821023952-922f4815f713
go: finding github.com/sirupsen/logrus v1.0.6
go: finding github.com/stretchr/testify v1.2.2
go: finding github.com/kr/text v0.1.0
go: finding github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78
go: finding github.com/hpcloud/tail v1.0.0
go: finding github.com/davecgh/go-spew v1.1.1
go: finding gopkg.in/airbrake/gobrake.v2 v2.0.9
go: finding github.com/docker/docker-credential-helpers v0.6.1
go: finding gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2
go: finding github.com/docker/distribution v2.6.2+incompatible
go: finding gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127
go: finding github.com/kr/pty v1.1.1
go: finding google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8
go: finding gopkg.in/fsnotify.v1 v1.4.7
go: finding github.com/docker/go-units v0.3.3
go: finding github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5
go: finding github.com/opencontainers/go-digest v1.0.0-rc1
go: finding github.com/opencontainers/image-spec v1.0.1
go: finding gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
go: finding github.com/onsi/ginkgo v1.6.0
go: finding github.com/google/go-cmp v0.2.0
go: finding gopkg.in/yaml.v2 v2.2.1
go: finding github.com/pkg/errors v0.8.0
go: finding golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac
go: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
go: downloading github.com/docker/docker v0.7.3-0.20181221150755-2cb26cfe9cbf
go: downloading github.com/docker/docker-credential-helpers v0.6.1
go: downloading github.com/docker/go-connections v0.4.0
go: extracting github.com/docker/docker-credential-helpers v0.6.1
go: extracting github.com/docker/go-connections v0.4.0
go: downloading github.com/stretchr/testify v1.2.2
go: extracting github.com/stretchr/testify v1.2.2
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: extracting github.com/pmezard/go-difflib v1.0.0
go: extracting github.com/davecgh/go-spew v1.1.1
go: extracting github.com/docker/docker v0.7.3-0.20181221150755-2cb26cfe9cbf
go: downloading gotest.tools v2.1.0+incompatible
go: downloading github.com/docker/go-units v0.3.3
go: downloading github.com/opencontainers/image-spec v1.0.1
go: downloading github.com/gogo/protobuf v1.1.1
go: extracting github.com/docker/go-units v0.3.3
go: extracting gotest.tools v2.1.0+incompatible
go: downloading github.com/google/go-cmp v0.2.0
go: extracting github.com/opencontainers/image-spec v1.0.1
go: downloading github.com/pkg/errors v0.8.0
go: downloading github.com/opencontainers/go-digest v1.0.0-rc1
go: extracting github.com/pkg/errors v0.8.0
go: extracting github.com/opencontainers/go-digest v1.0.0-rc1
go: extracting github.com/google/go-cmp v0.2.0
go: extracting github.com/gogo/protobuf v1.1.1

$ go build

$

@bcmills
Copy link
Contributor

bcmills commented Dec 21, 2018

The problems in these cases are semantic defects in the declared requirements, not directly due to replace directives. We should do more to prevent those semantic defects, rather than attributing them to only-semi-related features that are working as documented.

@bcmills
Copy link
Contributor

bcmills commented Dec 21, 2018

I think the thing that will fix the semantic defects is #29182, or perhaps #26420 (comment). Closing as a duplicate of those.

@bcmills bcmills closed this as completed Dec 21, 2018
@golang golang locked and limited conversation to collaborators Dec 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants