Skip to content

Module's local transitive dependencies work only with explicit replace directive #57056

Closed as not planned
@asmundak

Description

@asmundak

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

$ go version
go version go1.20-pre3 cl/474093167 +a813be86df linux/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="$HOME/.cache/go-build"
GOENV="$HOME/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="$HOME/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="$HOME/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/google-golang"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/google-golang/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20-pre3 cl/474093167 +a813be86df"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
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 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2517995585=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version go1.20-pre3 cl/474093167 +a813be86df linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.20-pre3 cl/474093167 +a813be86df
uname -sr: Linux 5.18.16-1rodete4-amd64
Distributor ID:	Debian
Description:	Debian GNU/Linux rodete
Release:	rodete
Codename:	rodete
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Debian GLIBC 2.35-1) stable release version 2.35.
gdb --version: GNU gdb (GDB) 10.0-gg5

What did you do?

There are three local modules, with top depending on middle, and middle depending on bottom

$ find . -type f -printf "\n---%P---\n" -exec cat {} \;

---middle/go.mod---
module middle
require _/bottom v0.0.0-00010101000000-000000000000
replace _/bottom => ../bottom
go 1.20

---middle/middle.go---
package middle
import "_/bottom"
var X = bottom.X

---top/go.mod---
module main
require _/middle v0.0.0-00010101000000-000000000000
replace _/middle => ../middle
go 1.20

---top/top.go---
package main
import "_/middle"
func main() {
	println(middle.X)
}

---bottom/go.mod---
module bottom
go 1.20

---bottom/bottom.go---
package bottom
var X int = 1

What did you expect to see?

cd top && go run . should succeed

What did you see instead?

$ (cd top && go run .)
../middle/middle.go:2:8: missing go.sum entry for module providing package _/bottom (imported by _/middle); to add:
	go get _/[email protected]

Doing what is suggested doesn't help:

$ (cd top && go get _/[email protected])
_/middle imports
	_/bottom: malformed module path "_/bottom": missing dot in first path element

What does help is explicitly adding replace directive to top/go.mod:

(cd top && go mod edit -replace _/bottom=../bottom && go mod tidy)
$ (cd top && go run .)
1

Requesting that a module keeps track of all its transitive local dependencies is IMHO a maintenance problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.modules

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions