Skip to content

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

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

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. FrozenDueToAge 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/[email protected]
go: downloading github.com/go-delve/delve v1.7.1-0.20210804080032-f95340ae1bf9
go get: github.com/go-delve/delve/cmd/[email protected]: 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/[email protected] 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/[email protected]/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/[email protected]
../../n/go/pkg/mod/golang.org/x/[email protected]/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/[email protected]
$ go get golang.org/x/tools/internal/[email protected]
go get: golang.org/x/tools/internal/[email protected]: 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
Member

@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
Member

@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/[email protected]
go: downloading github.com/go-delve/delve v1.7.1-0.20210804080032-f95340ae1bf9
go: github.com/go-delve/delve/cmd/[email protected]: 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/[email protected]
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/[email protected]
go: downloading github.com/go-delve/delve v1.7.1-0.20210804080032-f95340ae1bf9
go: github.com/go-delve/delve/cmd/[email protected]: 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 <[email protected]>
Run-TryBot: Bryan Mills <[email protected]>
Auto-Submit: Bryan Mills <[email protected]>
Reviewed-by: Michael Matloob <[email protected]>
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 <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Bryan Mills <[email protected]>
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 <[email protected]>
Run-TryBot: Bryan Mills <[email protected]>
Auto-Submit: Bryan Mills <[email protected]>
Reviewed-by: Michael Matloob <[email protected]>
@golang golang locked and limited conversation to collaborators Dec 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FixPending Issues that have a fix which has not yet been reviewed or submitted. FrozenDueToAge 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