Skip to content

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

Open

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

Activity

  1. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Jan 20, 2021
  2. added this to the Go1.17 milestone on Jan 20, 2021
  3. bcmills commented on Jan 20, 2021

    @bcmills
    Contributor

    This is because ../a/b is interpreted as a relative package path rather than a relative file path, I think.

    What should happen in the analogous situation where the module is located at ./a/b and the user runs go list ./a/b?
    (https://play.golang.org/p/C3qTwKrW2vJ)
    Should that also be interpreted as a file path?

    What if the path includes a ... wildcard, such as ./a/b/... or ./a/... or ../a/... or ../a/b/...?

  4. jayconrod commented on Jan 20, 2021

    @jayconrod
    ContributorAuthor

    ../a/b is being interpreted as a file path; the problem is with file paths into nested replacement modules in general. I get the same error with an absolute path.

    Listing a package in example.com/a works:

    $ go list ../a
    example.com/a
    

    The wildcard causes a different error, whether or not the module is in a nested replacement. This might be WAI though.

    $ go list ../a/...
    pattern ../a/...: directory /Users/jayconrod/Code/test/a is outside module root (/Users/jayconrod/Code/test/m)
    $ go list ../a/b/...
    pattern ../a/b/...: directory /Users/jayconrod/Code/test/a/b is outside module root (/Users/jayconrod/Code/test/m)
    
  5. jayconrod commented on Jan 20, 2021

    @jayconrod
    ContributorAuthor

    The context for this is this golang-nuts thread by the way.

  6. added
    okay-after-beta1Used by release team to mark a release-blocker issue as okay to resolve either before or after beta1
    on May 17, 2021
  7. modified the milestones: Go1.17, Go1.18 on Jul 29, 2021
  8. removed
    okay-after-beta1Used by release team to mark a release-blocker issue as okay to resolve either before or after beta1
    on Aug 11, 2021
  9. ianlancetaylor commented on Nov 17, 2021

    @ianlancetaylor
    Contributor

    This is in the Go1.18 milestone. Is it likely to happen for 1.18? Thanks.

  10. ianlancetaylor commented on Jan 28, 2022

    @ianlancetaylor
    Contributor

    @bcmills This is in the 1.18 milestone; time to move to 1.19? Thanks.

  11. modified the milestones: Go1.18, Go1.19 on Feb 1, 2022
  12. ianlancetaylor commented on Jun 24, 2022

    @ianlancetaylor
    Contributor

    @bcmills @matloob This issue is marked for 1.19. It's just been rolling forward in milestones. Should it move to Backlog?

  13. 4 remaining items

  14. modified the milestones: Go1.21, Go1.22 on Aug 8, 2023
  15. modified the milestones: Go1.22, Go1.23 on Feb 6, 2024
  16. modified the milestones: Go1.23, Go1.24 on Aug 13, 2024
  17. modified the milestones: Go1.24, Go1.25 on Feb 11, 2025
  18. modified the milestones: Go1.25, Go1.26 on Aug 12, 2025
  19. modified the milestones: Go1.26, Go1.27 on Feb 10, 2026
  20. modified the milestones: Go1.27, Backlog on Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions