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: describe replacements in dependency modules in case of a build failure #42717

Open
Spground opened this issue Nov 19, 2020 · 4 comments
Labels
FeatureRequest modules NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@Spground
Copy link

Spground commented Nov 19, 2020

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

$ go version

go version go1.14.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="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/spground/Library/Caches/go-build"
GOENV="/Users/spground/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOOS="darwin"
GOPATH="/Users/spground/go"
GOPROXY="http://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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/n1/tx8c68cs7dz04f741k98qn8r0000gp/T/go-build130682422=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

As discussion in #39358, replace and exclude directive will be ignored in modules except main module. However, we only get some simple error build info like build error in test.go:123:456 when running go command such as go test or go build if we forgot to add replace or exclude directive in go.mod file of main module. These simple error build info is not enough to guide me to add what statement in go.mod file of main module. Meanwhile, these simple build error message does not hint to me that the problem is about replace directive missing, which will get worse if i am not familiar with some dependent modules.

What did you expect to see?

Do more work to find which dependency introducing problems.

What did you see instead?

go command such as go test, go build will show more detail message related in replace directive topic in situation that replace directive missing in main module.

@gopherbot gopherbot added this to the Proposal milestone Nov 19, 2020
@ALTree
Copy link
Member

ALTree commented Nov 19, 2020

This doesn't need to go through the proposal process, that's only for significant changes in the language or the standard library.

@ALTree ALTree changed the title proposal: show more helpful guide message when main module needs to add replace directive in it's go.mod cmd/go: show more helpful guide message when main module needs to add replace directive in it's go.mod Nov 19, 2020
@ALTree ALTree removed the Proposal label Nov 19, 2020
@ALTree ALTree removed this from the Proposal milestone Nov 19, 2020
@ALTree ALTree added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Nov 19, 2020
@bcmills bcmills changed the title cmd/go: show more helpful guide message when main module needs to add replace directive in it's go.mod cmd/go: describe replacements in dependency modules in case of a build failure Nov 19, 2020
@bcmills bcmills added this to the Unplanned milestone Nov 19, 2020
@bcmills
Copy link
Contributor

bcmills commented Nov 19, 2020

CC @jayconrod @matloob

@bcmills
Copy link
Contributor

bcmills commented Nov 19, 2020

These simple error build info is not enough to guide me to add what statement in go.mod file of main module. Meanwhile, these simple build error message does not hint to me that the problem is about replace directive missing

In general the solution to this sort of problem is not to add your own replace directive; rather, it is to fix whatever dependency has the replace directive so that it works with the same versions of other modules that everyone else uses.

I think it might be reasonable to surface the replace directives from dependencies in case of a build error involving those dependencies, but we should still report the problem as a build error, not suggest adding a replace directive.

@Spground
Copy link
Author

@bcmills Thank you for your reply.

In general the solution to this sort of problem is not to add your own replace directive; rather, it is to fix whatever dependency has the replace directive so that it works with the same versions of other modules that everyone else uses.

It's true that we should fix whatever dependency has the replace directive when those dependencies are belong to us. However, sometimes we may import some 3rd party modules has some replace directives, which will make things hard.

I think it might be reasonable to surface the replace directives from dependencies in case of a build error involving those dependencies, but we should still report the problem as a build error, not suggest adding a replace directive.

Exactly, I think that build error message involving those dependencies is enough to find out what's wrong with build failure. Suggest adding a replace directive maybe mislead user, so it's better to let user decide what to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest modules NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

4 participants