Skip to content

cmd/go: go get -tool doesn't fully/correctly downgrade tools #71694

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
kalafut opened this issue Feb 12, 2025 · 2 comments
Closed

cmd/go: go get -tool doesn't fully/correctly downgrade tools #71694

kalafut opened this issue Feb 12, 2025 · 2 comments
Labels
BugReport Issues describing a possible bug in the Go implementation.

Comments

@kalafut
Copy link

kalafut commented Feb 12, 2025

Go version

go version go1.24.0 darwin/arm64

Output of go env in your module/workspace:

AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/kalafut/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/kalafut/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/8g/lzt1h1v95nn6_d96pqxn37km0000gp/T/go-build1618631231=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/kalafut/dev/XXXXXXXXXXX/backend/go.mod'
GOMODCACHE='/Users/kalafut/go/pkg/mod'
GONOPROXY='github.com/XXXXXXXXXXXXX/*'
GONOSUMDB='github.com/XXXXXXXXXXXXX/*'
GOOS='darwin'
GOPATH='/Users/kalafut/go'
GOPRIVATE='github.com/XXXXXXXXXXXXX/*'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/Users/kalafut/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.0'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

I tried the new go tool command with https://sqlc.dev. Installation and a version upgrade worked fine, but a version downgrade left the tool broken. go mod tidy didn't help. I had to revert the changes to go.mod and start anew.

$ go tool sqlc version
go: no such tool "sqlc"

$ go get -tool github.com/sqlc-dev/sqlc/cmd/sqlc@v1.27.0
go: added github.com/antlr4-go/antlr/v4 v4.13.1
go: added github.com/cubicdaiya/gonp v1.0.4
go: upgraded github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369 => v0.0.0-20181122101859-297441e03548
go: added github.com/dustin/go-humanize v1.0.1
go: added github.com/fatih/structtag v1.2.0
go: added github.com/google/cel-go v0.21.0
go: added github.com/hashicorp/golang-lru/v2 v2.0.7
go: added github.com/inconshreveable/mousetrap v1.1.0
go: added github.com/jinzhu/inflection v1.0.0
go: added github.com/ncruces/go-strftime v0.1.9
go: added github.com/pganalyze/pg_query_go/v5 v5.1.0
go: added github.com/pingcap/errors v0.11.5-0.20210425183316-da1aaba5fb63
go: added github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c
go: added github.com/pingcap/log v1.1.0
go: added github.com/pingcap/tidb/pkg/parser v0.0.0-20231103154709-4f00ece106b1
go: upgraded github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 => v0.0.0-20230129092748-24d4a6f8daec
go: added github.com/riza-io/grpc-go v0.2.0
go: added github.com/spf13/cobra v1.8.1
go: added github.com/sqlc-dev/sqlc v1.27.0
go: added github.com/stoewer/go-strcase v1.2.0
go: added github.com/tetratelabs/wazero v1.7.3
go: added github.com/wasilibs/go-pgquery v0.0.0-20240606042535-c0843d6592cc
go: added github.com/wasilibs/wazero-helpers v0.0.0-20240604052452-61d7981e9a38
go: upgraded go.uber.org/atomic v1.9.0 => v1.11.0
go: upgraded go.uber.org/multierr v1.10.0 => v1.11.0
go: upgraded go.uber.org/zap v1.21.0 => v1.26.0
go: added gopkg.in/natefinch/lumberjack.v2 v2.2.1
go: added modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6
go: upgraded modernc.org/libc v1.17.1 => v1.55.3
go: upgraded modernc.org/mathutil v1.5.0 => v1.6.0
go: upgraded modernc.org/memory v1.2.1 => v1.8.0
go: upgraded modernc.org/sqlite v1.18.1 => v1.31.1
go: upgraded modernc.org/strutil v1.1.3 => v1.2.0
go: upgraded modernc.org/token v1.0.0 => v1.1.0

$ go tool sqlc version                                  
v1.27.0

$ go get -tool github.com/sqlc-dev/sqlc/cmd/sqlc@v1.28.0
go: upgraded cel.dev/expr v0.16.2 => v0.18.0
go: upgraded github.com/google/cel-go v0.21.0 => v0.22.1
go: upgraded github.com/pingcap/errors v0.11.5-0.20210425183316-da1aaba5fb63 => v0.11.5-0.20240311024730-e056997136bb
go: upgraded github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c => v0.0.0-20240528011301-b51a646c7c86
go: upgraded github.com/pingcap/tidb/pkg/parser v0.0.0-20231103154709-4f00ece106b1 => v0.0.0-20241203170126-9812d85d0d25
go: upgraded github.com/sqlc-dev/sqlc v1.27.0 => v1.28.0
go: upgraded github.com/tetratelabs/wazero v1.7.3 => v1.8.2
go: upgraded go.uber.org/zap v1.26.0 => v1.27.0
go: upgraded modernc.org/sqlite v1.31.1 => v1.34.5

$ go tool sqlc version                                  
v1.28.0

$ go get -tool github.com/sqlc-dev/sqlc/cmd/sqlc@v1.27.0
go: downgraded github.com/sqlc-dev/sqlc v1.28.0 => v1.27.0

$ go tool sqlc version                                  
# github.com/sqlc-dev/sqlc/internal/engine/dolphin
../../../go/pkg/mod/github.com/sqlc-dev/sqlc@v1.27.0/internal/engine/dolphin/convert.go:918:46: undefined: pcast.IndexAdviseStmt
../../../go/pkg/mod/github.com/sqlc-dev/sqlc@v1.27.0/internal/engine/dolphin/convert.go:1641:14: undefined: pcast.IndexAdviseStmt

$ go mod tidy     
$ go tool sqlc version
# github.com/sqlc-dev/sqlc/internal/engine/dolphin
../../../go/pkg/mod/github.com/sqlc-dev/sqlc@v1.27.0/internal/engine/dolphin/convert.go:918:46: undefined: pcast.IndexAdviseStmt
../../../go/pkg/mod/github.com/sqlc-dev/sqlc@v1.27.0/internal/engine/dolphin/convert.go:1641:14: undefined: pcast.IndexAdviseStmt

$ git checkout -f
$ go tool sqlc version
go: no such tool "sqlc"

$ go get -tool github.com/sqlc-dev/sqlc/cmd/sqlc@v1.27.0
go: added github.com/antlr4-go/antlr/v4 v4.13.1
go: added github.com/cubicdaiya/gonp v1.0.4
go: upgraded github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369 => v0.0.0-20181122101859-297441e03548
go: added github.com/dustin/go-humanize v1.0.1
go: added github.com/fatih/structtag v1.2.0
go: added github.com/google/cel-go v0.21.0
go: added github.com/hashicorp/golang-lru/v2 v2.0.7
go: added github.com/inconshreveable/mousetrap v1.1.0
go: added github.com/jinzhu/inflection v1.0.0
go: added github.com/ncruces/go-strftime v0.1.9
go: added github.com/pganalyze/pg_query_go/v5 v5.1.0
go: added github.com/pingcap/errors v0.11.5-0.20210425183316-da1aaba5fb63
go: added github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c
go: added github.com/pingcap/log v1.1.0
go: added github.com/pingcap/tidb/pkg/parser v0.0.0-20231103154709-4f00ece106b1
go: upgraded github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 => v0.0.0-20230129092748-24d4a6f8daec
go: added github.com/riza-io/grpc-go v0.2.0
go: added github.com/spf13/cobra v1.8.1
go: added github.com/sqlc-dev/sqlc v1.27.0
go: added github.com/stoewer/go-strcase v1.2.0
go: added github.com/tetratelabs/wazero v1.7.3
go: added github.com/wasilibs/go-pgquery v0.0.0-20240606042535-c0843d6592cc
go: added github.com/wasilibs/wazero-helpers v0.0.0-20240604052452-61d7981e9a38
go: upgraded go.uber.org/atomic v1.9.0 => v1.11.0
go: upgraded go.uber.org/multierr v1.10.0 => v1.11.0
go: upgraded go.uber.org/zap v1.21.0 => v1.26.0
go: added gopkg.in/natefinch/lumberjack.v2 v2.2.1
go: added modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6
go: upgraded modernc.org/libc v1.17.1 => v1.55.3
go: upgraded modernc.org/mathutil v1.5.0 => v1.6.0
go: upgraded modernc.org/memory v1.2.1 => v1.8.0
go: upgraded modernc.org/sqlite v1.18.1 => v1.31.1
go: upgraded modernc.org/strutil v1.1.3 => v1.2.0
go: upgraded modernc.org/token v1.0.0 => v1.1.0

$ go tool sqlc version                                  
v1.27.0

What did you see happen?

Compilation failures of the tool occurred after specifying a lower version.

What did you expect to see?

I expect to be able change the tool version as needed without error. I can do this today with go run, for example:

$ go run github.com/sqlc-dev/sqlc/cmd/sqlc@v1.27.0 version
v1.27.0

$ go run github.com/sqlc-dev/sqlc/cmd/sqlc@v1.28.0 version
go: downloading google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53
go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53
v1.28.0

$ go run github.com/sqlc-dev/sqlc/cmd/sqlc@v1.27.0 version
v1.27.0

@kalafut kalafut changed the title cmd/go: get -tool doesn't fully/correctly downgrade tools cmd/go: go get -tool doesn't fully/correctly downgrade tools Feb 12, 2025
@seankhliao
Copy link
Member

this is like any other dependency, upgrading can bring in newer versions of indirect dependencies, these aren't downgraded , but are incompatible with older versions of your direct dependency

go run pkg@version is not comparable because it's stateless every time.

closing as while it may be unfortunately, it's working as intended

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Feb 12, 2025
@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation.
Projects
None yet
Development

No branches or pull requests

3 participants