CircleCI-Public / go-orb

https://circleci.com/orbs/registry/orb/circleci/go
MIT License
9 stars 37 forks source link

odd build problem with cached Go 1.17.6 executable #53

Open eli-darkly opened 2 years ago

eli-darkly commented 2 years ago

I have a CI job that runs on a machine executor and installs Go with the go/install command from the Go orb.

I was previously using Go 1.16.10 and everything was working fine. Then I changed the Go version to 1.17.6, and even though the Go install step still seemed to work, as soon as I tried to build some Go code I got errors like this:

/usr/local/go/src/runtime/internal/sys/stubs.go:9:7: PtrSize redeclared in this block
    /usr/local/go/src/runtime/internal/sys/arch.go:24:38: previous declaration
/usr/local/go/src/runtime/internal/sys/stubs.go:10:24: undefined: Uintreg
/usr/local/go/src/runtime/internal/sys/stubs.go:16:7: StackGuardMultiplier redeclared in this block
    /usr/local/go/src/runtime/internal/sys/arch.go:27:74: previous declaration

Online advice like this generally agreed that this meant a corrupt Go installation, possibly due to not removing a previous installation. So, I tried setting the cache-key parameter to bust the cache so there couldn't be any previous installation. That fixed the build... at least, until the next time I ran it, at which point it failed again.

It looks to me like this failure is correlated with whether the Go orb is reusing a cached version of /usr/local/go/bin/go or not. I don't see how it could be caching an invalid executable, because in the previous test run that succeeded, it was using that very same executable. But, so far, this is very reproducible and I can't get the build to stay green except by setting cache: false.

david-montano-circleci commented 1 week ago

Hello @eli-darkly . Thank you for reporting this issue and sorry for the late response.

It is common to have incompatibilities while upgrading Go versions. Given that in this scenario you were already using a cache, once you decide to update the Go version, we recommend to update the go/install call, specifically the cache-key parameter to create a whole new caching storage with the new Go version. This way you will make sure that there will not be traces of the previous version in your Filesystem.