Skip to content
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

cmd/go: incorrect message when replace target fails to resolve to correct module #34256

Closed
myitcv opened this issue Sep 12, 2019 · 4 comments
Closed
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@myitcv
Copy link
Member

myitcv commented Sep 12, 2019

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

$ go version
go version devel +396d625330 Thu Sep 12 07:45:53 2019 +0000 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/myitcv/.cache/go-build"
GOENV="/home/myitcv/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/myitcv/gos"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build854839250=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Consider the following testscript test:

go mod tidy

-- tools.go --
// +build tools

package tools

import (
        _ "golang.org/x/tools/go/analysis"
        _ "golang.org/x/tools/gopls"
)

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

go 1.13

require (
        golang.org/x/tools v0.0.0-20190911230505-6bfd74cf029c
        golang.org/x/tools/gopls v0.1.5
)

replace golang.org/x/tools => github.com/myitcvforks/tools v0.0.0-20190911230505-6bfd74cf029c

replace golang.org/x/tools/gopls => github.com/myitcvforks/tools v0.0.0-20190911230505-6bfd74cf029c

What did you expect to see?

An error telling me the replace for golang.org/x/tools/gopls is incorrect because the target of the replace is the module golang.org/x/tools

What did you see instead?

go: github.com/myitcvforks/tools@v0.0.0-20190911230505-6bfd74cf029c: parsing go.mod:
        module declares its path as: golang.org/x/tools
                but was required as: github.com/myitcvforks/tools

cc @bcmills @jayconrod

@myitcv myitcv added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go modules labels Sep 12, 2019
@bcmills
Copy link
Contributor

bcmills commented Sep 12, 2019

Somewhat related to #34085, in that we are reporting the replacement path in place of what should be the module it replaces.

@bcmills bcmills added this to the Go1.14 milestone Sep 12, 2019
@myitcv
Copy link
Member Author

myitcv commented Sep 12, 2019

Ah thanks. Feel free to close if you think it's a duplicate. I searched for "required as" hence I didn't spot #34085

@bcmills
Copy link
Contributor

bcmills commented Sep 12, 2019

I don't think the fix for #34085 will address this case, so it's probably better to keep as a separate issue.

@bcmills
Copy link
Contributor

bcmills commented Nov 9, 2020

Seems to be fixed as of Go 1.16. (I'm not sure when exactly, but there have been a lot of fixes in the module loader this cycle.)

hello$ go mod tidy
go: golang.org/x/tools/gopls@v0.1.5 (replaced by github.com/myitcvforks/tools@v0.0.0-20190911230505-6bfd74cf029c): parsing go.mod:
        module declares its path as: golang.org/x/tools
                but was required as: golang.org/x/tools/gopls

@bcmills bcmills closed this as completed Nov 9, 2020
@bcmills bcmills modified the milestones: Backlog, Go1.16 Nov 9, 2020
@golang golang locked and limited conversation to collaborators Nov 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go 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