Skip to content

cmd/go: confusing error on mod edit -replace=old=.. #30514

@mvdan

Description

@mvdan

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

go version devel +44d3bb998c Fri Mar 1 07:45:00 2019 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What did you do?

$ mkdir test
$ cd test
$ go mod init test
go: creating new go.mod: module test
$ go mod edit -replace=foo.com/bar=..
go mod: -replace=foo.com/bar=..: invalid new path: malformed module path "..": double dot
$ go mod edit -replace=foo.com/bar=../
$ cat go.mod
module test

go 1.13

replace foo.com/bar => ../

What did you expect to see?

Replacing a module to .. would either succeed or give a useful error.

What did you see instead?

An error saying "double dot", which makes no sense to me as a user. It was @myitcv who pointed out that adding a trailing slash would fix the problem.

From go help go mod:

If the @v in new@v is omitted, the new path hould be a local module root directory, not a module path.

So nothing in the error nor the docs seemed to point me at the missing slash.

/cc @bcmills

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.modules

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions