Skip to content

cmd/go: 'go get' of module in GOPATH mode fails due to semantic version import #35630

@nmiyake

Description

@nmiyake

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

$ go version
go version go1.13.4 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

Official golang:1.13.4 Docker image:

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
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-build017263389=/tmp/go-build -gno-record-gcc-switches"

What did you do?

GO111MODULE=off go get github.com/mholt/archiver

(or a simple go get github.com/mholt/archiver in a GOPATH with no go.mod)

What did you expect to see?

Success: github.com/mholt/archiver and all of its dependencies should be fetched and exist in their proper locations within $GOPATH/src

What did you see instead?

package github.com/pierrec/lz4/v3: cannot find package "github.com/pierrec/lz4/v3" in any of:
	/usr/local/go/src/github.com/pierrec/lz4/v3 (from $GOROOT)
	/go/src/github.com/pierrec/lz4/v3 (from $GOPATH)

Details

github.com/mholt/archiver was recently updated to use Go modules. As part of this upgrade, one of its dependencies was upgraded to use github.com/pierrec/lz4/v3, which is another module. This module is at github.com/pierrec/lz4 (it does not explicitly create a "v3" directory).

It appears that there are clients that use "go get" in GOPATH mode to populate their GOPATH with their dependencies to build their projects in CI (presumably they are not vendoring). In this mode, "go get" can no longer be used to properly populate the GOPATH.

Setting GO111MODULE=on go get github.com/mholt/archiver causes the "get" operation to succeed, but is not helpful since it does not actually populate the GOPATH.

I believe that if the GOPATH were properly populated, the minimal module compatibility code would allow the project to build. However, there does not seem to be any way to use go get to populate the GOPATH properly in this scenario.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions