Skip to content

cmd/go: "no required module provides package" error with file path to replacement module inside another replacement #43806

@jayconrod

Description

@jayconrod

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

$ go version
go version go1.16beta1 darwin/amd64
go version go1.15.6 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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jayconrod/Library/Caches/go-build"
GOENV="/Users/jayconrod/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/jayconrod/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/jayconrod/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/go/installed"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/go/installed/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16beta1"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/jayconrod/Code/test/m/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/rq/x0692kqj6ml8cvrhcqh5bswc008xj1/T/go-build3064706002=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Create three local modules: M (main module, requiring and replacing the other two), A (module in a directory outside M), and B (module in a subdirectory of A).

Attempt to list a package in B using a relative or absolute file path.

cd m
go list ../a   # works
go list ../a/b # fails

-- m/go.mod --
module example.com/m

go 1.15

require (
	example.com/a v0.0.0
	example.com/b v0.0.0
)

replace (
	example.com/a v0.0.0 => ../a
	example.com/b v0.0.0 => ../a/b
)
-- a/go.mod --
module example.com/a
-- a/a.go --
package a
-- a/b/go.mod --
module example.com/b

go 1.15
-- a/b/b.go --
package b

What did you expect to see?

Package name is printed successfully:

example.com/a/b

What did you see instead?

$ go list ../a/b
no required module provides package example.com/a/b; try 'go get -d example.com/a/b' to add it

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions