Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
asmundak opened this issue Dec 2, 2022 · 5 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@asmundak
Copy link

asmundak commented Dec 2, 2022

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.

@seankhliao
Copy link
Member

Working as intended, replace directives only apply at the main module, if you need to work with multiple modules, consider using workspaces.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Dec 2, 2022
@bcmills

This comment was marked as outdated.

@bcmills bcmills reopened this Dec 2, 2022
@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. modules labels Dec 2, 2022
@bcmills bcmills added this to the Backlog milestone Dec 2, 2022
@bcmills
Copy link
Contributor

bcmills commented Dec 2, 2022

@seankhliao
Copy link
Member

doesn't top have no require / replace for _/bottom, and the error comes from _/bottom being an unretrievable module?

@bcmills
Copy link
Contributor

bcmills commented Dec 2, 2022

Ah, you're right! The error message _/bottom: malformed module path "_/bottom": missing dot in first path element is indeed for that module.

@bcmills bcmills closed this as not planned Won't fix, can't repro, duplicate, stale Dec 2, 2022
@golang golang locked and limited conversation to collaborators Dec 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants