little-angry-clouds / kubernetes-binaries-managers

Kubernetes related binaries manager.
GNU General Public License v3.0
101 stars 11 forks source link

Golang 1.18 compatility #32

Closed dsiebel closed 2 years ago

dsiebel commented 2 years ago

I recently started setting up my new MacbookPro with Apple Silicon, part of which is installing helmenv via Brewfile:

tap "little-angry-clouds/homebrew-my-brews"
brew "helmenv" 

I kept running into that issue where Golang would complain about

//go:linkname must refer to declared function or variable

and I found various "fixes" on Github and Stack Overflow suggesting to install via Rosetta. I tried it and the error remained the same. I then tried building helmenv locally using CGO_ENABLED=0 go build -a -o helmenv cmd/helmenv/main.go and the issue remained the same (which is to expected, now that I checked the homebrew formula).

The underlying issue seems to be an incompatibility with go1.18.2 involving the golang.org/x/sys library. I cloned the repo, upgraded to go 1.18 and golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a and I was able to build helmenv succefully.

Since I can not foresee the sideeffects this might have on the other cmds I thought I'd ask for feedback here, before creating a Pull Request.

mkurde commented 2 years ago

I was running into a similar issue with my own go app and found [1].

The solution for me was an update of golang.org/x/sys

go get -u golang.org/x/sys

[1] https://stackoverflow.com/questions/71507321/go-1-18-build-error-on-mac-unix-syscall-darwin-1-13-go253-golinkname-mus

dsiebel commented 2 years ago

go get -u golang.org/x/sys

This solution I found in many places, but it doesn't work when installing homebrew formulas from source because you would need to run it inside the formula somehow.

dsiebel commented 2 years ago

Steps that fixed the issue for me:

git clone git@github.com:little-angry-clouds/kubernetes-binaries-managers.git
cd kubernetes-binaries-managers
go get -u golang.org/x/sys
make build
cp bin/helmenv /usr/local/bin/helmenv
cp bin/helm-wrapper /usr/local/bin/helm
alexppg commented 2 years ago

So I've launched a new version. I've updated the dependencies, but also I moved to goreleaser and brew will now download pre-complied binaries, so this problem should never happen again. It will also be a little bit cleaner.

Could somebody please upgrade from brew and see if it works as expected?

dsiebel commented 2 years ago

Could somebody please upgrade from brew and see if it works as expected?

Will do, thanks for the timely fix!

dsiebel commented 2 years ago

Not sure if this is due to my environment, but this is what I get:

~ » brew tap little-angry-clouds/my-brews
[...]
~ » brew install helmenv
Error: formulae require at least a URL
Please report this issue:
  https://docs.brew.sh/Troubleshooting
/opt/homebrew/Library/Homebrew/formula.rb:273:in `determine_active_spec'
/opt/homebrew/Library/Homebrew/formula.rb:208:in `initialize'
/opt/homebrew/Library/Homebrew/formulary.rb:181:in `new'
/opt/homebrew/Library/Homebrew/formulary.rb:181:in `get_formula'
/opt/homebrew/Library/Homebrew/formulary.rb:420:in `factory'
/opt/homebrew/Library/Homebrew/cli/parser.rb:633:in `block in formulae'
/opt/homebrew/Library/Homebrew/cli/parser.rb:629:in `map'
/opt/homebrew/Library/Homebrew/cli/parser.rb:629:in `formulae'
/opt/homebrew/Library/Homebrew/cli/parser.rb:308:in `parse'
/opt/homebrew/Library/Homebrew/cmd/install.rb:141:in `install'
/opt/homebrew/Library/Homebrew/brew.rb:110:in `<main>'

EDIT: looks to me like the formula does not contain any Darwin release anymore https://github.com/little-angry-clouds/homebrew-my-brews/blob/master/Formula/helmenv.rb#L10

dsiebel commented 2 years ago

Also: when I repeat the steps from my previous comment with the current master branch and run helm I get the following "error":

~/w/s/kubernetes-binaries-managers » helm
[1]    28385 killed     helm

When I use helm-wrapper instead of helm as a name it works...

ghost commented 2 years ago

@alexppg The missing Darwin brew configuration in the formula is a problem for me as well.

alexppg commented 2 years ago

My bad, I forgot to add the arm64 url for macOs, sorry. Could you pleas try again?

ghost commented 2 years ago

@alexppg It should be on_macos, not on_darwin in the formula

alexppg commented 2 years ago

You're right, changed.

ghost commented 2 years ago

Now it works

dsiebel commented 2 years ago

Confirmed, work now. Thanks!

alexppg commented 2 years ago

Thanks to all your help!