Go v1.18 breaks installation procedure in docs
Hello all,
I upgraded to Go v1.18 over the weekend, and the installation instructions under Getting Started -> Installing Ginkgo no longer work.
The following is the output I receive when attempting to run go get github.com/onsi/ginkgo/v2/ginkgo in the golang:latest container. I have achieved similar results in a Github Action:
# go install github.com/onsi/ginkgo/v2/ginkgo
/go/pkg/mod/github.com/onsi/ginkgo/[email protected]/ginkgo/generators/bootstrap_command.go:9:2: missing go.sum entry for module providing package github.com/go-task/slim-sprig (imported by github.com/onsi/ginkgo/v2/ginkgo/generators); to add:
go get github.com/onsi/ginkgo/v2/ginkgo/[email protected]
/go/pkg/mod/github.com/onsi/ginkgo/[email protected]/ginkgo/internal/profiles_and_reports.go:12:2: missing go.sum entry for module providing package github.com/google/pprof/profile (imported by github.com/onsi/ginkgo/v2/ginkgo/internal); to add:
go get github.com/onsi/ginkgo/v2/ginkgo/[email protected]
/go/pkg/mod/github.com/onsi/ginkgo/[email protected]/ginkgo/labels/labels_command.go:15:2: missing go.sum entry for module providing package golang.org/x/tools/go/ast/inspector (imported by github.com/onsi/ginkgo/v2/ginkgo/labels); to add:
go get github.com/onsi/ginkgo/v2/ginkgo/[email protected]
This matches the Go dev blog's notes around the deprecation of go get as an installer. That said, replacing get with install doesn't work either.
The fix I found is to double up the get and install commands like so:
go get -d github.com/onsi/ginkgo/v2/ginkgo && go install github.com/onsi/ginkgo/v2/ginkgo
Based on my own efforts, installing GInkgo this way doesn't break Go v1.17, but I didn't test on earlier versions. I've also been unable to replicate a need to explicitly invoke go get github.com/onsi/gomega/....
I'm happy to PR the change into the docs, but I didn't know if it was going to be part of a larger update in the works.
hey @bdshroyer - there are no bigger plans at the moment, no. I don't think I understand why go install is failing since the go docs seem to indicate that that should work. but if go get followed by go install works then that's what we need to do I suppose. please do submit a PR for the docs.
I found a little bit more about go install's behavior in the build command flags. Specifically, the -mod flag is set to readonly by default when the Go version in go.mod is below 1.14 (GInkgo's is 1.12). The readonly mode raises the errors we see above when it can't find a module in the cache--it was just never an issue before because all the modules were being downloaded in advance by the go get installation process.
When you run go get or go get -d before running install, or if you install using go get on Go 1.17, you can see the modules with missing go sums getting downloaded (as well as ginkgo v1.16.5 for some reason):
| go: downloading github.com/onsi/ginkgo v1.16.5
| go: downloading golang.org/x/tools v0.1.9
| go: downloading github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0
| go: downloading github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38
Similarly, if you run go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo you can see it downloading the missing modules as well, and ginkgo installs successfully.
Given all this, I'll probably put go install -mod=mod in my PR, since one command is generally preferable to two.
💯 thanks for digging into it @bdshroyer !