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
342 stars 29 forks source link

Installation of a module (shfmt) failed but it is listed as installed #104

Open mbideau opened 2 years ago

mbideau commented 2 years ago

bingo version output:

❯ bingo version
v0.5.1

go version output:

❯ go version
go version go1.15.9 linux/amd64

What happened: installation of a module (shfmt) failed but it is listed as installed

What you expected to happen: installation of a module (shfmt) failed but it is NOT listed as installed

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

❯ (cd $(mktemp -d) && pwd && bingo get -v -l mvdan.cc/sh/v3/cmd/shfmt || ls -alh && ls -alh .bingo && bingo list)
/tmp/tmp.0og4C9XseM
Bingo not used before here, creating directory for pinned modules for you at .bingo
getting target mvdan.cc/sh/v3/cmd/shfmt (module  )
exec 'go mod init -modfile=/tmp/tmp.0og4C9XseM/.bingo/shfmt-e.tmp.mod _'
exec 'go get -modfile=/tmp/tmp.0og4C9XseM/.bingo/shfmt-e.tmp.mod -d mvdan.cc/sh/v3/cmd/shfmt'
exec 'go env GOPATH'
exec 'go mod init -modfile=/tmp/tmp.0og4C9XseM/.bingo/shfmt.tmp.mod _'
exec 'go list -modfile=/tmp/tmp.0og4C9XseM/.bingo/shfmt.tmp.mod -mod=mod -f={{.Name}} mvdan.cc/sh/v3/cmd/shfmt'
Error: install: build versioned: /home/michael/go/pkg/mod/mvdan.cc/sh/v3@v3.4.0/cmd/shfmt/main.go:11:2: package io/fs is not in GOROOT (/usr/lib/go-1.15/src/io/fs)
: error while running command 'go build -modfile=/tmp/tmp.0og4C9XseM/.bingo/shfmt.tmp.mod -o=shfmt-v3.4.0 mvdan.cc/sh/v3/cmd/shfmt'; err: exit status 1
shfmt.mod: getting mvdan.cc/sh/v3/cmd/shfmt
main.get
    /home/michael/go/pkg/mod/github.com/bwplotka/bingo@v0.5.1/get.go:298
main.main.func2
    /home/michael/go/pkg/mod/github.com/bwplotka/bingo@v0.5.1/main.go:158
main.main.func5
    /home/michael/go/pkg/mod/github.com/bwplotka/bingo@v0.5.1/main.go:227
github.com/oklog/run.(*Group).Run.func1
    /home/michael/go/pkg/mod/github.com/oklog/run@v1.1.0/group.go:38
runtime.goexit
    /usr/lib/go-1.15/src/runtime/asm_amd64.s:1374
get
main.main.func2
    /home/michael/go/pkg/mod/github.com/bwplotka/bingo@v0.5.1/main.go:159
main.main.func5
    /home/michael/go/pkg/mod/github.com/bwplotka/bingo@v0.5.1/main.go:227
github.com/oklog/run.(*Group).Run.func1
    /home/michael/go/pkg/mod/github.com/oklog/run@v1.1.0/group.go:38
runtime.goexit
    /usr/lib/go-1.15/src/runtime/asm_amd64.s:1374
get command failed
main.main
    /home/michael/go/pkg/mod/github.com/bwplotka/bingo@v0.5.1/main.go:235
runtime.main
    /usr/lib/go-1.15/src/runtime/proc.go:204
runtime.goexit
    /usr/lib/go-1.15/src/runtime/asm_amd64.s:1374

total 0
drwx------ 1 michael michael   12 12 nov.  12:36 .
drwxrwxrwt 1 root    root    2,5K 12 nov.  12:36 ..
drwxr-xr-x 1 michael michael  102 12 nov.  12:36 .bingo
total 20K

drwxr-xr-x 1 michael michael  102 12 nov.  12:36 .
drwx------ 1 michael michael   12 12 nov.  12:36 ..
-rw-r--r-- 1 michael michael  116 12 nov.  12:36 .gitignore
-rw-r--r-- 1 michael michael  148 12 nov.  12:36 go.mod
-rw-r--r-- 1 michael michael  820 12 nov.  12:36 README.md
-rw-r--r-- 1 michael michael  130 12 nov.  12:36 shfmt.tmp.mod
-rw-r--r-- 1 michael michael 2,6K 12 nov.  12:36 shfmt.tmp.sum

Name    Binary Name Package @ Version       Build EnvVars   Build Flags
----    ----------- -----------------       -------------   -----------
shfmt   shfmt-v3.4.0    mvdan.cc/sh/v3/cmd/shfmt@v3.4.0         

Anything else we need to know:

May be there should be a rollback mechanism in case of failure, or even better "transactional/atomic operations", maybe using temporary directories which content is copied to .bingo folder only if it succeeds.