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: malformed module path with retract v2+ [1.16 backport] #44496

Closed
gopherbot opened this issue Feb 22, 2021 · 7 comments
Closed

cmd/go: malformed module path with retract v2+ [1.16 backport] #44496

gopherbot opened this issue Feb 22, 2021 · 7 comments

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Feb 22, 2021

@bcmills requested issue #44494 (fixed by bcac57f and 5fafc0b in Go 1.17) to be considered for backport to the next 1.16 minor release.

@gopherbot, please backport to Go 1.16.

@bcmills
Copy link
Member

@bcmills bcmills commented Feb 22, 2021

The rationale for this backport is that the erroneous error message is very confusing, and there is no workaround for confusion.

@cagedmantis
Copy link
Contributor

@cagedmantis cagedmantis commented Feb 25, 2021

Approved. This is a serious issue.

@gopherbot
Copy link
Author

@gopherbot gopherbot commented Mar 2, 2021

Change https://golang.org/cl/297989 mentions this issue: [release-branch.go1.16] cmd/go/internal/modload: don't query when fixing canonical versions

@gopherbot
Copy link
Author

@gopherbot gopherbot commented Mar 2, 2021

Change https://golang.org/cl/298010 mentions this issue: [internal-branch.go1.16-vendor] modfile: defer fixing versions in retract directives

gopherbot pushed a commit to golang/mod that referenced this issue Mar 2, 2021
…ract directives

VersionFixers require both a path and a version: if the version is
non-canonical (like a branch name), they generally need the path to
look up the proper version. This is fine for require, replace, and
exclude directives, since the path is specified with each version. For
retract directives, the path comes from the module directive, which
may appear later in the file. Previously, we just used the empty
string, but this breaks reasonable implementations.

With this change, we leave retracted versions alone until the file has
been completely parsed, then we apply the version fixer to each
retract directive. We report an error if retract is used without a
module directive.

For golang/go#44496

Change-Id: I99b7b8b55941c1fde4ee56161acfe854bcaf948d
Reviewed-on: https://go-review.googlesource.com/c/mod/+/296130
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit 66bf157)
Reviewed-on: https://go-review.googlesource.com/c/mod/+/298010
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Mar 2, 2021

Change https://golang.org/cl/297990 mentions this issue: [release-branch.go1.16] cmd: upgrade golang.org/x/mod to fix go.mod parser

gopherbot pushed a commit that referenced this issue Mar 3, 2021
…arser

modfile.Parse passed an empty string to the VersionFixer for the
module path. This caused errors for v2+ versions.

For #44496

Change-Id: I13b86b6ecf6815c4bc9a96ec0668284c9228c205
Reviewed-on: https://go-review.googlesource.com/c/go/+/296131
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit bcac57f)
Reviewed-on: https://go-review.googlesource.com/c/go/+/297990
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
gopherbot pushed a commit that referenced this issue Mar 3, 2021
…ing canonical versions

If a canonical version is passed to fixVersion when loading the main
go.mod and that version don't match the module path's major version
suffix, don't call Query.

Query doesn't return a useful error in this case when the path is
malformed, for example, when it doens't have a dot in the first path
element. It's better to report the major version mismatch error.

Fixes #44496

Change-Id: I97b1f64aee894fa0db6fb637aa03a51357ee782c
Reviewed-on: https://go-review.googlesource.com/c/go/+/296590
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit 5fafc0b)
Reviewed-on: https://go-review.googlesource.com/c/go/+/297989
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Mar 3, 2021

Closed by merging a9ba734 to release-branch.go1.16.

@gopherbot gopherbot closed this Mar 3, 2021
@gopherbot

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants