bwplotka / bingo

Like `go get` but for Go tools! CI Automating versioning of Go binaries in a nested, isolated Go modules.
Apache License 2.0
351 stars 29 forks source link

Bingo get fails complaining go1.18+ required which is already the case #125

Closed unicell closed 1 year ago

unicell commented 1 year ago

bingo version output:

v0.7

go version output:

go version go1.18.3 linux/amd64

What happened:

Failed to run bingo get for this particular go package.

$ bingo list
Name Binary Name Package @ Version Build EnvVars Build Flags
---- ----------- ----------------- ------------- -----------
$ bingo get github.com/hofstadter-io/hof/cmd/hof@v0.6.7-rc.2
Bingo not used before here, creating directory for pinned modules for you at .bingo
Error: get command failed: get: hof.mod: getting github.com/hofstadter-io/hof/cmd/hof@v0.6.7-rc.2: install: build versioned: # github.com/hofstadter-io/cinful
/mnt/gocode/pkg/mod/github.com/hofstadter-io/cinful@v1.0.0/cinful.go:25:11: undeclared name: any (requires version go1.18 or later)
/mnt/gocode/pkg/mod/github.com/hofstadter-io/cinful@v1.0.0/cinful.go:26:11: undeclared name: any (requires version go1.18 or later)
: exit 1

What you expected to happen:

Expecting bingo get to succeed, since:

go install works just fine

$  go install github.com/hofstadter-io/hof/cmd/hof@v0.6.7-rc.2

and the underlying go build command bingo runs also works fine.

$ cd .bingo/
$ ls .bingo/
README.md go.mod hof.tmp.mod hof.tmp.sum
$ GOWORK=off go build -mod=mod -modfile=hof.tmp.mod -o=./hof-v0.6.7-rc.2 "github.com/hofstadter-io/hof/cmd/hof"
$ ls
README.md go.mod hof-v0.6.7-rc.2 hof.tmp.mod hof.tmp.sum

How to reproduce it (as minimally and precisely as possible):

mkdir testdir; cd testdir
bingo get github.com/hofstadter-io/hof/cmd/hof@v0.6.7-rc.2

Logs (use bingo get -v <thing you do> for verbose output):

$  bingo get -v github.com/hofstadter-io/hof/cmd/hof@v0.6.7-rc.2
getting target github.com/hofstadter-io/hof/cmd/hof@v0.6.7-rc.2 (module  )
exec 'go mod init -modfile=/mnt/test/.bingo/hof-e.tmp.mod _'
exec 'go get -modfile=/mnt/test/.bingo/hof-e.tmp.mod -d github.com/hofstadter-io/hof/cmd/hof@v0.6.7-rc.2'
resolveInGoModCache: Found /mnt/gocode/pkg/mod/cache/download/github.com/hofstadter-io/hof/cmd/hof/@v directory
resolveInGoModCache: /mnt/gocode/pkg/mod/cache/download/github.com/hofstadter-io/hof/cmd/hof/@v/v0.6.7-rc.2.info file not exists. Looking for +incompatible info file
resolveInGoModCache: /mnt/gocode/pkg/mod/cache/download/github.com/hofstadter-io/hof/cmd/hof/@v/v0.6.7-rc.2+incompatible.info file not exists. Looking for different module
resolveInGoModCache: /mnt/gocode/pkg/mod/cache/download/github.com/hofstadter-io/hof/cmd/@v directory does not exists
resolveInGoModCache: Found /mnt/gocode/pkg/mod/cache/download/github.com/hofstadter-io/hof/@v directory
exec 'go env GOPATH'
exec 'go mod init -modfile=/mnt/test/.bingo/hof.tmp.mod _'
exec 'go list -modfile=/mnt/test/.bingo/hof.tmp.mod -mod=mod -f={{.Name}} github.com/hofstadter-io/hof/cmd/hof'
Error: get command failed
> main.main     /mnt/gocode/pkg/mod/github.com/bwplotka/bingo@v0.7.0/main.go:223
> runtime.main  /mnt/go/src/runtime/proc.go:250
> runtime.goexit        /mnt/go/src/runtime/asm_amd64.s:1571
get
> main.main.func2       /mnt/gocode/pkg/mod/github.com/bwplotka/bingo@v0.7.0/main.go:147
> main.main.func5       /mnt/gocode/pkg/mod/github.com/bwplotka/bingo@v0.7.0/main.go:215
> github.com/oklog/run.(*Group).Run.func1       /mnt/gocode/pkg/mod/github.com/oklog/run@v1.1.0/group.go:38
> runtime.goexit        /mnt/go/src/runtime/asm_amd64.s:1571
hof.mod: getting github.com/hofstadter-io/hof/cmd/hof@v0.6.7-rc.2
> main.get      /mnt/gocode/pkg/mod/github.com/bwplotka/bingo@v0.7.0/get.go:290
> main.main.func2       /mnt/gocode/pkg/mod/github.com/bwplotka/bingo@v0.7.0/main.go:146
> main.main.func5       /mnt/gocode/pkg/mod/github.com/bwplotka/bingo@v0.7.0/main.go:215
> github.com/oklog/run.(*Group).Run.func1       /mnt/gocode/pkg/mod/github.com/oklog/run@v1.1.0/group.go:38
> runtime.goexit        /mnt/go/src/runtime/asm_amd64.s:1571
install: build versioned: # github.com/hofstadter-io/cinful
/mnt/gocode/pkg/mod/github.com/hofstadter-io/cinful@v1.0.0/cinful.go:25:11: undeclared name: any (requires version go1.18 or later)
/mnt/gocode/pkg/mod/github.com/hofstadter-io/cinful@v1.0.0/cinful.go:26:11: undeclared name: any (requires version go1.18 or later)
: error while running command 'go build -modfile=/mnt/test/.bingo/hof.tmp.mod -o=/mnt/gocode/bin/hof-v0.6.7-rc.2 github.com/hofstadter-io/hof/cmd/hof'; err: exit status 2

Anything else we need to know:

Red-GV commented 1 year ago

If you need a workaround for this, I've found that setting the go.mod file to go 1.16 allows tools to be pinned correctly.

sevein commented 1 year ago

Is this perhaps related to issue https://github.com/golang/go/issues/54908 in Go?

0xERR0R commented 1 year ago

Am I getting this right: it is a bug in Go and it will be fixed in Go 1.20?

martin-sucha commented 1 year ago

I see similar issue when installing golangci-lint, even with Go 1.20. I've opened https://github.com/golang/go/issues/58388

martin-sucha commented 1 year ago

It seems that the go list -mod=mod command does not update the mod/sum files like go mod tidy does. Bingo should perhaps do this instead:

bwplotka commented 1 year ago

Thanks for this, I was just investigating this. Especially https://github.com/golang/go/issues/58388 is super helpful 💪🏽

I assume the .sum is not up to date for our .mod? It's really annoying go mod tidy does not have modfile flag...

I think the best way would be to create tmp dir only to execute go mod tidy and remove after done... PRs welcome, otherwise I will do it later this week.

bwplotka commented 1 year ago

Closing dup: https://github.com/bwplotka/bingo/issues/128