Closed daogilvie closed 11 months ago
So along with updating the Go version used in the binary distribution, I also upgraded the action version:
I have a sneaking suspicion this is to blame. Let me check.
I can't debug this at the moment, I need to get home to my mac laptop and see if I can reproduce this.
I wasn't able to find any smoking gun within the setup-go action, nor with gorereleaser. Although, there are docs in goreleaser for adding os-specific hooks, and funnily enough one of the examples is with using codesign: https://goreleaser.com/customization/builds/?h=codesign#build-hooks
We could probably just do this. Although, I would really like to know what the difference is between your environment and everyone else's.
Although, I would really like to know what the difference is between your environment and everyone else's.
You and me both! I'm sure this is some weird thing on my machine, coupled with some corner case in the mockery code, rather than a general problem with mockery.
Thank you for responding so quickly β I am completely unfamiliar with Go internals, and with the details of MacOS code signatures, so I'm really lost on what to check next. Whatever happens I'm sure it'll be a learning experience. To be clear, I'm absolutely fine if the outcome of this issue is a big ole shrug Β―_(γ)_/Β― and closing it because it just can't be replicated. I hoped if anyone was seeing this too, or knew what I might be able to check next, then this would be the place to find out π
I think I've identified where the problem might lie, and it's in my specific toolchain of Go for some reason. I will continue to investigate, but I've now managed to replicate on one other non-trivial Go project so I think the ball is back in my court! I'll close the issue here, thank you again for your time, and for maintaining mockery!
Just as a note for interest β this was caused for some reason by my Go toolchain using clang
from homebrew's latest stable LLVM (17.0.2) instead of cc
or regular Xcode tools clang
. May learn some more from the wise folks over at brew, but definitely not a mockery problem.
Description
Mockery binaries don't seem correctly signed on MacOS under go 1.21, even when built from source and ad-hoc signed. I'm on MacOS 13.6 (22G120) on an M1 (so apple silicon).
I have Apple-silicon-using colleagues who do not have this problem β I do not think this is a widespread bug on your code specifically, but it only happens with this repository for me.
I can get the binary to run by re-signing it (
codesign -s - mockery
). This issue does not occur when installing viabrew
, because they re-sign everything anyway (see https://github.com/Homebrew/brew/issues/9082). Go wrestled with this first happening in 2020, and this does not happen with other Go code on my machine, whethergo install
ing orgo build
ing it.The tests run fine, so the intermediate test binary being built clearly does not suffer from whatever this problem is.
I'm quite new to Go so might be missing something obvious; if there is something more useful I can do on this issue, then please just let me know.
Thanks for making and improving mockery π!
Mockery Version
This seems to be the case with all commits after d5024915e0bbc049b4fb49ce8cb62a68f23fa59e, up to and including 8939c75f51783166286c150e25a50aa8f8b9037c (determined by
git bisect
).Golang Version
Error happens with 1.21.0-3
When building with 1.20.6, the binary runs, but there is a build warning printed that seems possibly related:
Installation Method
exec /usr/local/bin/mockery: exec format error
regardless of requesting amd64 or arm64 builds)Steps to Reproduce
go clean -i -r -x
go build; ./mockery
codesign -v mockery
will fail, complaining:Expected Behavior
Actual Behavior