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: improve error message for replace with '@' in path #35041

Closed
jayconrod opened this issue Oct 21, 2019 · 3 comments
Closed

cmd/go: improve error message for replace with '@' in path #35041

jayconrod opened this issue Oct 21, 2019 · 3 comments
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@jayconrod
Copy link
Contributor

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

$ go version
go version go1.13.3 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=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jayconrod/Library/Caches/go-build"
GOENV="/Users/jayconrod/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/jayconrod/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/go/installed"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/go/installed/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/jayconrod/Code/test/go.mod"
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/rq/x0692kqj6ml8cvrhcqh5bswc008xj1/T/go-build363012595=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

cat >go.mod <<EOF
module m

go 1.13

require golang.org/x/tools v1.0.0

replace golang.org/x/tools@v1.0.0 => golang.org/x/tools@v1.1.0
EOF

go list -m all

What did you expect to see?

Error message indicating that I should have written:

replace golang.org/x/tools v1.0.0 => golang.org/x/tools v1.1.0

instead of

replace golang.org/x/tools@v1.0.0 => golang.org/x/tools@v1.1.0

What did you see instead?

go: errors parsing go.mod:
/Users/jayconrod/Code/test/go.mod:7: replacement module without version must be directory path (rooted or starting with ./ or ../)

I think the parser is interpreting golang.org/x/tools@v1.0.0 as a module path without a version. @ is not a valid character in module paths, so this seems like an obvious mistake we could catch.

@jayconrod jayconrod added NeedsFix The path to resolution is known, but the work has not been done. GoCommand cmd/go modules labels Oct 21, 2019
@jayconrod jayconrod added this to the Backlog milestone Oct 21, 2019
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/408014 mentions this issue: x/mod: improve error message for replace with '@' in path

@dmitshur
Copy link
Contributor

dmitshur commented Aug 10, 2022

(The new x/mod version will need to be brought into the main repo, and that'll happen during the Go 1.20 cycle at the very least via #36905.)

@gopherbot

This comment was marked as off-topic.

@golang golang locked and limited conversation to collaborators Sep 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go modules 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