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 on a pseudo-version of a package not at the repo root fails with preceding tag (…) not found when fetching from git #47650

Closed
bcmills opened this issue Aug 11, 2021 · 15 comments
Assignees
Labels
FixPending Issues that have a fix which has not yet been reviewed or submitted. GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Aug 11, 2021

From a report from @hyangah:

$ go1.17rc2 mod init example.com/m
go: creating new go.mod: module example.com/m

$ export GOPRIVATE=github.com/go-delve/delve

$ go1.17rc2 get -d github.com/go-delve/delve/cmd/dlv@v1.7.1-0.20210804080032-f95340ae1bf9
go: downloading github.com/go-delve/delve v1.7.1-0.20210804080032-f95340ae1bf9
go get: github.com/go-delve/delve/cmd/dlv@v1.7.1-0.20210804080032-f95340ae1bf9: invalid pseudo-version: preceding tag (v1.7.0) not found

$ go1.17rc2 get -d github.com/go-delve/delve/cmd/dlv@f95340ae1bf9
go: downloading github.com/sirupsen/logrus v1.6.0
go: downloading github.com/spf13/cobra v1.1.3
go: downloading github.com/mattn/go-isatty v0.0.3
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/cosiner/argv v0.1.0
go: downloading github.com/mattn/go-colorable v0.0.9
go: downloading github.com/peterh/liner v0.0.0-20170317030525-88609521dc4b
go: downloading github.com/google/go-dap v0.5.0
go: downloading golang.org/x/sys v0.0.0-20210514084401-e8d321eab015
go: downloading go.starlark.net v0.0.0-20200821142938-949cc6f4b097
go: downloading github.com/hashicorp/golang-lru v0.5.4
go: downloading golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4
go: downloading github.com/aquasecurity/libbpfgo v0.1.2-0.20210708203834-4928d36fafac
go: downloading github.com/konsorten/go-windows-terminal-sequences v1.0.3
go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/inconshreveable/mousetrap v1.0.0
go: downloading github.com/russross/blackfriday/v2 v2.0.1
go: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0
go get: added github.com/aquasecurity/libbpfgo v0.1.2-0.20210708203834-4928d36fafac
go get: added github.com/cosiner/argv v0.1.0
go get: added github.com/cpuguy83/go-md2man/v2 v2.0.0
go get: added github.com/go-delve/delve v1.7.1-0.20210804080032-f95340ae1bf9
go get: added github.com/google/go-dap v0.5.0
go get: added github.com/hashicorp/golang-lru v0.5.4
go get: added github.com/inconshreveable/mousetrap v1.0.0
go get: added github.com/konsorten/go-windows-terminal-sequences v1.0.3
go get: added github.com/mattn/go-colorable v0.0.9
go get: added github.com/mattn/go-isatty v0.0.3
go get: added github.com/peterh/liner v0.0.0-20170317030525-88609521dc4b
go get: added github.com/russross/blackfriday/v2 v2.0.1
go get: added github.com/shurcooL/sanitized_anchor_name v1.0.0
go get: added github.com/sirupsen/logrus v1.6.0
go get: added github.com/spf13/cobra v1.1.3
go get: added github.com/spf13/pflag v1.0.5
go get: added go.starlark.net v0.0.0-20200821142938-949cc6f4b097
go get: added golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4
go get: added golang.org/x/sys v0.0.0-20210514084401-e8d321eab015
go get: added gopkg.in/yaml.v2 v2.4.0
@bcmills bcmills added modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Aug 11, 2021
@bcmills bcmills added this to the Go1.18 milestone Aug 11, 2021
@bcmills bcmills self-assigned this Aug 11, 2021
@bcmills
Copy link
Contributor Author

bcmills commented Aug 11, 2021

$ git version
git version 2.33.0.rc1.237.g0d66db33f3-goog

(because it isn't clear to me whether this is actually a bug in git or cmd/go.)

@bcmills
Copy link
Contributor Author

bcmills commented Aug 11, 2021

Interestingly, go1.17rc2 mod download -x github.com/go-delve/delve@v1.7.1-0.20210804080032-f95340ae1bf9 doesn't reproduce the error. So I suspect that this has something to do with looking for nested modules before the root module. (Perhaps we're fetching the nested-module tags but caching them as though we had downloaded the root-module tags?)

@aarzilli
Copy link
Contributor

aarzilli commented Dec 3, 2021

FWIW I'm running into something very similar to this with golang.org/x/tools:

$ go get -u golang.org/x/tools@master
go get: upgraded golang.org/x/mod v0.4.2 => v0.5.1
go get: upgraded golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e => v0.0.0-20211019181941-9d821ace8654
go get: upgraded golang.org/x/tools v0.1.7 => v0.1.8-0.20211202032535-e212aff8fd14
$ go build
../../n/go/pkg/mod/golang.org/x/tools@v0.1.8-0.20211202032535-e212aff8fd14/internal/gocommand/vendor.go:17:2: missing go.sum entry for module providing package golang.org/x/mod/semver (imported by golang.org/x/tools/internal/gocommand); to add:
	go get golang.org/x/tools/internal/gocommand@v0.1.8-0.20211202032535-e212aff8fd14
../../n/go/pkg/mod/golang.org/x/tools@v0.1.8-0.20211202032535-e212aff8fd14/go/packages/external.go:15:2: missing go.sum entry for module providing package golang.org/x/sys/execabs (imported by golang.org/x/tools/go/packages); to add:
	go get golang.org/x/tools/go/packages@v0.1.8-0.20211202032535-e212aff8fd14
$ go get golang.org/x/tools/internal/gocommand@v0.1.8-0.20211202032535-e212aff8fd14
go get: golang.org/x/tools/internal/gocommand@v0.1.8-0.20211202032535-e212aff8fd14: invalid pseudo-version: preceding tag (v0.1.7) not found

This is with GOPROXY=direct, happens on go1.17 and go1.18. Git version 2.25.1.

@ianlancetaylor
Copy link
Contributor

@bcmills This is in the 1.18 milestone; time to move to 1.19? Thanks.

@bcmills bcmills modified the milestones: Go1.18, Go1.19 Feb 1, 2022
@ianlancetaylor
Copy link
Contributor

@bcmills @matloob This issue is marked for 1.19. It's just been rolling forward in milestones. Should it move to Backlog? Thanks.

@bcmills
Copy link
Contributor Author

bcmills commented Jun 28, 2022

It should still be fixed — it's a fairly serious issue in version resolution. Unfortunately it needs some involved work to fix correctly, and I've had limited capability for focused work this cycle due to burnout.

@tuxillo
Copy link
Contributor

tuxillo commented Mar 20, 2023

Not sure if this is the same but it seems it could be like #58116:

# go version
go version go1.19.5 dragonfly/amd64
thor# go clean -modcache
# go install golang.org/x/tools@master
go: downloading golang.org/x/tools v0.7.1-0.20230317165317-fa556487c5c2
go: golang.org/x/tools@master: module golang.org/x/tools@master found (v0.7.1-0.20230317165317-fa556487c5c2), but does not contain package golang.org/x/tools

Got this error too while building packages for DragonFlyBSD. Example:

-- Phase: extract
-------------------------------------------------------------------------------

===>  License MIT accepted by the user
===>   rclone-1.61.1_2 depends on file: /usr/local/sbin/pkg - found
===>   rclone-1.61.1_2 depends on file: /usr/local/bin/go119 - found
===>   rclone-1.61.1_2 depends on package: ca_root_nss>0 - found
===> Fetching all distfiles required by rclone-1.61.1_2 for building
===> Fetching github.com/rclone/rclone dependencies
===>  Extracting for rclone-1.61.1_2
=> SHA256 Checksum OK for go/net_rclone/rclone-v1.61.1/v1.61.1.mod.
=> SHA256 Checksum OK for go/net_rclone/rclone-v1.61.1/v1.61.1.zip.
===> Tidying github.com/rclone/rclone dependencies
go: finding module for package github.com/hanwen/go-fuse/v2/fuse
go: finding module for package github.com/ncw/go-acd
[...]
go: finding module for package github.com/golang/protobuf/ptypes/empty
github.com/rclone/rclone/backend/amazonclouddrive imports
	github.com/ncw/go-acd: module github.com/ncw/go-acd@latest found (v0.0.0-20201019170801-fe55f33415b1), but does not contain package github.com/ncw/go-acd
github.com/rclone/rclone/backend/box imports
	github.com/youmark/pkcs8: module github.com/youmark/pkcs8@latest found (v0.0.0-20201027041543-1326539a0a0a), but does not contain package github.com/youmark/pkcs8
github.com/rclone/rclone/backend/cache imports
	github.com/patrickmn/go-cache: module github.com/patrickmn/go-cache@latest found (v2.1.0+incompatible), but does not contain package github.com/patrickmn/go-cache
github.com/rclone/rclone/backend/cache imports
	go.etcd.io/bbolt: module go.etcd.io/bbolt@latest found (v1.3.6), but does not contain package go.etcd.io/bbolt
github.com/rclone/rclone/backend/compress imports
	github.com/buengese/sgzip: module github.com/buengese/sgzip@latest found (v0.1.1), but does not contain package github.com/buengese/sgzip

Is there any workaround?

@kylechadha
Copy link

kylechadha commented Mar 27, 2023

@tuxillo Not sure if this is the same issue as described above (I see it in 1.20.2), but I installed 1.19.7 and that worked for me: #59281

@bcmills
Copy link
Contributor Author

bcmills commented May 11, 2023

This may be related to #56881.

@gopherbot gopherbot modified the milestones: Go1.21, Go1.22 Aug 8, 2023
@bcmills bcmills added the GoCommand cmd/go label Dec 7, 2023
@bcmills
Copy link
Contributor Author

bcmills commented Dec 7, 2023

Thankfully, the original reproducer for this still succeeds in reproducing it, so I hope to make progress on it soon.

$ ~/go/bin/go version
go version devel go1.22-bb34112d4d Thu Dec 7 17:27:54 2023 +0000 linux/amd64

$ ~/go/bin/go mod init example.com/m
go: creating new go.mod: module example.com/m

$ export GOPRIVATE=github.com/go-delve/delve

$ ~/go/bin/go get github.com/go-delve/delve/cmd/dlv@v1.7.1-0.20210804080032-f95340ae1bf9
go: downloading github.com/go-delve/delve v1.7.1-0.20210804080032-f95340ae1bf9
go: github.com/go-delve/delve/cmd/dlv@v1.7.1-0.20210804080032-f95340ae1bf9: invalid pseudo-version: preceding tag (v1.7.0) not found

$ ~/go/bin/go get github.com/go-delve/delve/cmd/dlv@f95340ae1bf9
go: downloading github.com/mattn/go-isatty v0.0.3
go: downloading github.com/sirupsen/logrus v1.6.0
go: downloading github.com/spf13/cobra v1.1.3
go: downloading github.com/google/go-dap v0.5.0
go: downloading golang.org/x/sys v0.0.0-20210514084401-e8d321eab015
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/cosiner/argv v0.1.0
go: downloading github.com/mattn/go-colorable v0.0.9
go: downloading github.com/peterh/liner v0.0.0-20170317030525-88609521dc4b
go: downloading github.com/hashicorp/golang-lru v0.5.4
go: downloading golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4
go: downloading github.com/aquasecurity/libbpfgo v0.1.2-0.20210708203834-4928d36fafac
go: downloading go.starlark.net v0.0.0-20200821142938-949cc6f4b097
go: downloading github.com/konsorten/go-windows-terminal-sequences v1.0.3
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.0
go: downloading github.com/inconshreveable/mousetrap v1.0.0
go: downloading github.com/russross/blackfriday/v2 v2.0.1
go: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0
go: added github.com/aquasecurity/libbpfgo v0.1.2-0.20210708203834-4928d36fafac
go: added github.com/cosiner/argv v0.1.0
go: added github.com/cpuguy83/go-md2man/v2 v2.0.0
go: added github.com/go-delve/delve v1.7.1-0.20210804080032-f95340ae1bf9
go: added github.com/google/go-dap v0.5.0
go: added github.com/hashicorp/golang-lru v0.5.4
go: added github.com/inconshreveable/mousetrap v1.0.0
go: added github.com/konsorten/go-windows-terminal-sequences v1.0.3
go: added github.com/mattn/go-colorable v0.0.9
go: added github.com/mattn/go-isatty v0.0.3
go: added github.com/peterh/liner v0.0.0-20170317030525-88609521dc4b
go: added github.com/russross/blackfriday/v2 v2.0.1
go: added github.com/shurcooL/sanitized_anchor_name v1.0.0
go: added github.com/sirupsen/logrus v1.6.0
go: added github.com/spf13/cobra v1.1.3
go: added github.com/spf13/pflag v1.0.5
go: added go.starlark.net v0.0.0-20200821142938-949cc6f4b097
go: added golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4
go: added golang.org/x/sys v0.0.0-20210514084401-e8d321eab015
go: added gopkg.in/yaml.v2 v2.4.0

@bcmills
Copy link
Contributor Author

bcmills commented Dec 7, 2023

In this case the relevant tag is v1.7.0 (go-delve/delve@584191a), which is several commits prior to go-delve/delve@f95340a.

@bcmills
Copy link
Contributor Author

bcmills commented Dec 7, 2023

The subdirectory in the go get argument seems to be essential to reproduce the bug:

$ go clean -modcache

$ go get github.com/go-delve/delve@v1.7.1-0.20210804080032-f95340ae1bf9
go: downloading github.com/go-delve/delve v1.7.1-0.20210804080032-f95340ae1bf9
go: added github.com/go-delve/delve v1.7.1-0.20210804080032-f95340ae1bf9

$ go clean -modcache

$ go get github.com/go-delve/delve/cmd/dlv@v1.7.1-0.20210804080032-f95340ae1bf9
go: downloading github.com/go-delve/delve v1.7.1-0.20210804080032-f95340ae1bf9
go: github.com/go-delve/delve/cmd/dlv@v1.7.1-0.20210804080032-f95340ae1bf9: invalid pseudo-version: preceding tag (v1.7.0) not found

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/548475 mentions this issue: cmd/go: reproduce #47650

@JABirchall
Copy link

JABirchall commented Dec 8, 2023

I also ran into this issue when forking a project and changing imports to my new github url.
Not sure if this was something i did wrong or if this would be a reproducable method for the error.

I fixed it by doing 3 fake tags and on the 3rd try everything pulled correctly.

@bcmills bcmills changed the title cmd/go: preceding tags not always fetched when downloading a pseudo-version cmd/go: go get on a pseudo-version of a package not at the repo root fails with preceding tag (…) not found when fetching from git Dec 9, 2023
@bcmills bcmills added FixPending Issues that have a fix which has not yet been reviewed or submitted. NeedsFix The path to resolution is known, but the work has not been done. labels Dec 9, 2023
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 9, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/549155 mentions this issue: cmd/go: explicitly name the default branch “main” in testdata/vcstest/git/issue57650.txt

gopherbot pushed a commit that referenced this issue Dec 12, 2023
…/git/issue57650.txt

Updates #47650.

Change-Id: I90c0a51b390326129643d5b90fe935d44e5e5372
Reviewed-on: https://go-review.googlesource.com/c/go/+/549155
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
ezz-no pushed a commit to ezz-no/go-ezzno that referenced this issue Feb 18, 2024
…Query

If we encounter an unclassified error in modload.Query, it takes
precedence even if the package is found in some other module.
(That is intentional, so that if a package exists in both a parent
and a nested module the outcome is deterministic, and does not shift
if a temporary error causes one of the modules to be unavailable.)

A pseudo-version is formed from a base version and a commit hash.
Each version tag is specific to the module in a particular directory
of the repo (often the root directory), whereas the commit hash is
the same for all subdirectories. When we go to check a particular
subdirectory for the requested package, we may find that that version
is not valid for that combination of <subdirectory, commit hash>,
but we should keep looking to see whether it is valid for a module
in some other subdirectory.

Fixes golang#47650.

Change-Id: Id48f590ce906a3d4cf4e82fc66137bf67613277d
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/548475
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
ezz-no pushed a commit to ezz-no/go-ezzno that referenced this issue Feb 18, 2024
…/git/issue57650.txt

Updates golang#47650.

Change-Id: I90c0a51b390326129643d5b90fe935d44e5e5372
Reviewed-on: https://go-review.googlesource.com/c/go/+/549155
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FixPending Issues that have a fix which has not yet been reviewed or submitted. GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
Status: Done
Development

No branches or pull requests

7 participants