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

Unable to install a pinned version using go install #128

Closed
kameshsampath opened this issue Feb 7, 2023 · 9 comments · Fixed by #138
Closed

Unable to install a pinned version using go install #128

kameshsampath opened this issue Feb 7, 2023 · 9 comments · Fixed by #138

Comments

@kameshsampath
Copy link

/question

As developer trying to use docker-credential-gcr, I tried installing using go install

go install github.com/GoogleCloudPlatform/[email protected]

It results in the following error,

go: github.com/GoogleCloudPlatform/[email protected]: github.com/GoogleCloudPlatform/[email protected]: invalid version: module contains a go.mod file, so module path must match major version ("github.com/GoogleCloudPlatform/docker-credential-gcr/v2")

Based on the error I tried doing,

go install github.com/GoogleCloudPlatform/docker-credential-gcr/[email protected]

Which also results in same error as above.

If I do go install github.com/GoogleCloudPlatform/docker-credential-gcr@latest it works, but I need to pin to a version of the binary.

Any clues?

@eriksw
Copy link

eriksw commented May 30, 2023

Weird and probably related: If you install via an @<git sha> you get something that claims to be 1.5.1 but with the (much newer than 1.5.1) sha suffix at the end: #115

@rosmo
Copy link

rosmo commented May 31, 2023

I believe there would be need to copy the v2.0+ changes to a v2/ directory (and perhaps roll back the main directory to the last v1 release). (ref: https://go.dev/blog/v2-go-modules)

@sudo-bmitch
Copy link
Contributor

I believe this can be resolved by changing:

module github.com/GoogleCloudPlatform/docker-credential-gcr

From

module github.com/GoogleCloudPlatform/docker-credential-gcr

to

module github.com/GoogleCloudPlatform/docker-credential-gcr/v2

This also requires updating all imports in the various child packages so that they don't pull v1 code.

@liam-verta
Copy link

The bug here is that people can't install a pinned version.

WORKAROUND:
As @eriksw noted above, go install github.com/GoogleCloudPlatform/docker-credential-gcr@<commit-sha> installs the commit specified as expected. The version number looks strange, but the code is correct.

II think the v.1.5.1 in the version string is a side-effect of the go module version numbering rules around major versions (as noted with the error above): since github.com/GoogleCloudPlatform/docker-credential-gcr doesn't have /v2/ in it, the Go module system uses the the next reasonable v1 incremental number. There's already a v1.5.0, so commits after that tag must be at least v1.5.1-<something>.

I've done a file diff and verified that the code being pulled matches the commit-sha. docker-credential-gcr v2.1.8 and docker-credential-gcr 62afb2723512 are functionally the same. Only the version number is different.

@rafibarash
Copy link
Contributor

I'm a little hesitant to approve #138 - I don't believe I've used other github packages that need the /<version> suffix.

Could this instead be fixed with a change to the .goreleaser.yml file?

@eriksw
Copy link

eriksw commented Jun 16, 2023

@rafibarash No change to goreleaser configuration or bazel build rules could ever address this card. This tool needs to be buildable via normal "go install" and in order to do that it must comply with the requirement of a major version suffix. https://go.dev/ref/mod#major-version-suffixes

If there had never been any >=2 tags created then things could have carried on as is, but that ship has sailed.

@rafibarash
Copy link
Contributor

Sounds good, I'll create another release. Thanks for the fix!

@rafibarash
Copy link
Contributor

Well, look like a new but similar error popped up after https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/tag/v2.1.10.

rbarash:🏠 ❯ go install github.com/GoogleCloudPlatform/[email protected]

go: github.com/GoogleCloudPlatform/[email protected]: github.com/GoogleCloudPlatform/[email protected]: invalid version: go.mod has post-v2 module path "github.com/GoogleCloudPlatform/docker-credential-gcr/v2" at revision v2.1.10

Will look into a fix

@rafibarash rafibarash reopened this Jun 16, 2023
@rafibarash
Copy link
Contributor

Actually nvm, I forgot about adding the /v2 suffix when installing.

rbarash:🏠 ❯ go install github.com/GoogleCloudPlatform/docker-credential-gcr/[email protected]
go: downloading github.com/GoogleCloudPlatform/docker-credential-gcr/v2 v2.1.10

In hindsight, this should have been a major release change (v3.0.0) instead of a minor one. My apologies for not realizing that before merging your fix. I'm planning on leaving this be, but feel free to re-open the comment if you think it's necessary to also do a major version release.

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

Successfully merging a pull request may close this issue.

6 participants