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: 'go get […]/v2@v2.X.Y' fails when the repo root contains the go.mod file for […]/v2 but no .go source files #34746

Closed
bcmills opened this issue Oct 7, 2019 · 4 comments
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Oct 7, 2019

My fix for #34383 was incomplete: it failed to take into account the possibility that the longest path for the module would be a *PackageNotInModuleError, in which case we should prefer the *PackageNotInModuleError over an unclassified error from a module with a shorter path.

A reproducer:

example.com$ gotip version
go version devel +cfe23204 Sun Oct 6 18:18:50 2019 +0000 linux/amd64

example.com$ GOPROXY=direct gotip get vcs-test.golang.org/git/empty-v2-without-v1.git/v2@v2.0.0
go: finding vcs-test.golang.org/git/empty-v2-without-v1.git v2.0.0
go get vcs-test.golang.org/git/empty-v2-without-v1.git/v2@v2.0.0: vcs-test.golang.org/git/empty-v2-without-v1.git@v2.0.0: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2

CC @jayconrod

@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. modules labels Oct 7, 2019
@bcmills bcmills added this to the Go1.14 milestone Oct 7, 2019
@bcmills bcmills self-assigned this Oct 7, 2019
@bcmills
Copy link
Contributor Author

bcmills commented Oct 7, 2019

@gopherbot, please backport to 1.13. This was a regression, and the fix goes with #34497 (already backported).

@gopherbot
Copy link

Backport issue(s) opened: #34747 (for 1.13).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

@gopherbot
Copy link

Change https://golang.org/cl/199839 mentions this issue: cmd/go: suppress more errors in package-to-module loading

@gopherbot
Copy link

Change https://golang.org/cl/199997 mentions this issue: [release-branch.go1.13] cmd/go: suppress more errors in package-to-module loading

gopherbot pushed a commit that referenced this issue Oct 9, 2019
…dule loading

In CL 197059, I suppressed errors if the target package was already found.
However, that does not cover the case of passing a '/v2' module path to
'go get' when the module does not contain a package at its root.

This CL is a minimal fix for that case, intended to be backportable to 1.13.

(Longer term, I intend to rework the version-validation check to treat
all mismatched paths as ErrNotExist.)

Updates #34746
Fixes #34747

Change-Id: Ia963c2ea00fae424812b8f46a4d6c2c668252147
Reviewed-on: https://go-review.googlesource.com/c/go/+/199839
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
(cherry picked from commit 421d35c)
Reviewed-on: https://go-review.googlesource.com/c/go/+/199997
@golang golang locked and limited conversation to collaborators Oct 8, 2020
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants