You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/go: "no required module provides package" error with file path to replacement module inside another replacement #43806
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
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/...?
../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)
Activity
bcmills commentedon Jan 20, 2021
This is because
../a/bis 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/band the user runsgo 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/...?jayconrod commentedon Jan 20, 2021
../a/bis 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/aworks:The wildcard causes a different error, whether or not the module is in a nested replacement. This might be WAI though.
jayconrod commentedon Jan 20, 2021
The context for this is this golang-nuts thread by the way.
ianlancetaylor commentedon Nov 17, 2021
This is in the Go1.18 milestone. Is it likely to happen for 1.18? Thanks.
ianlancetaylor commentedon Jan 28, 2022
@bcmills This is in the 1.18 milestone; time to move to 1.19? Thanks.
ianlancetaylor commentedon Jun 24, 2022
@bcmills @matloob This issue is marked for 1.19. It's just been rolling forward in milestones. Should it move to Backlog?
4 remaining items