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: misleading error message for replacement module with capital letters #38220

Closed
retgits opened this issue Apr 2, 2020 · 2 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@retgits
Copy link

retgits commented Apr 2, 2020

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

$ go version
go version go1.14.1 darwin/amd64

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/lstigter/Library/Caches/go-build"
GOENV="/Users/lstigter/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/lstigter/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/4b/hq3khbrx30b_wk3fz63z9vww0000gq/T/go-build752664778=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I forked a project from https://github.com/wavefrontHQ/wavefront-lambda-go which doesn't use Go modules yet to help them adopt Go modules. I created a go.mod file, using

$ go mod init github.com/wavefrontHQ/wavefront-lambda-go
$ go mod tidy

That results in the go.mod file

module github.com/wavefronthq/wavefront-lambda-go

go 1.14

require (
	github.com/aws/aws-lambda-go v1.12.1
	github.com/rcrowley/go-metrics v0.0.0-20190706150252-9beb055b7962
	github.com/wavefronthq/go-metrics-wavefront v0.9.0
)

The resulting code was committed to the forked repo https://github.com/retgits/wavefront-lambda-go

In a project where I want to use this new module, I added a replace directive into my go.mod file to point to the new location

module github.com/retgits/acme-serverless-payment

replace github.com/wavefronthq/wavefront-lambda-go => github.com/retgits/wavefront-lambda-go v0.0.0-20200402174306-c89629d5856a

go 1.13

require (
	github.com/aws/aws-lambda-go v1.15.0
	github.com/aws/aws-sdk-go v1.29.27
	github.com/getsentry/sentry-go v0.5.1
	github.com/gofrs/uuid v3.2.0+incompatible
	github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
	github.com/pulumi/pulumi v1.12.1
	github.com/pulumi/pulumi-aws v1.26.0
	github.com/retgits/creditcard v0.6.0
	github.com/retgits/pulumi-helpers v0.1.3
	github.com/wavefronthq/wavefront-lambda-go v0.0.0-20190812171804-d9475d6695cc
	gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
	gopkg.in/yaml.v2 v2.2.8 // indirect
)

Running any of the go commands throws an error

What did you expect to see?

$go mod tidy
<no errors>

What did you see instead?

$ go mod tidy                                              
go: github.com/retgits/wavefront-lambda-go@v0.0.0-20200402161507-0edb5b9bfe10: parsing go.mod:
        module declares its path as: github.com/wavefrontHQ/wavefront-lambda-go
                but was required as: github.com/retgits/wavefront-lambda-go

The error message is a little misleading, and as @jayconrod discovered is about the capitalization of wavefrontHQ. After changing it all to lowercase in the module, it was solved.

@jayconrod jayconrod changed the title Misleading error message when module name has capital letters cmd/go: misleading error message for replacement module with capital letters Apr 2, 2020
@jayconrod jayconrod added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 2, 2020
@jayconrod jayconrod added this to the Go1.15 milestone Apr 2, 2020
@jayconrod
Copy link
Contributor

This error was also printed by go list -m all. Since it popped up during module loading, tools like go mod graph and go mod why weren't helpful for finding where the module was loaded (though in this case, it was loaded from the main module).

The error message should use the original module's path, not the replacement module path on the "required as" line.

go: github.com/retgits/wavefront-lambda-go@v0.0.0-20200402161507-0edb5b9bfe10: parsing go.mod:
        module declares its path as: github.com/wavefrontHQ/wavefront-lambda-go
                but was required as: github.com/wavefronthq/wavefront-lambda-go

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/227097 mentions this issue: cmd/go: report original module path in error parsing replaced go.mod

@golang golang locked and limited conversation to collaborators Apr 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants