kreuzwerker / m1-terraform-provider-helper

CLI to support with downloading and compiling terraform providers for Mac with M1 chip

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go dependency is met (but not actually satisfied)

mbd-s opened this issue · comments

This isn't really a bug, but I found this behavior surprising and thought it might be worthwhile to raise it here :)

I use asdf to manage go, among other things. The directory where I'm using m1-terraform-provider-helper isn't a go project, and I also don't have a global go version set. So even though m1-terraform-provider-helper's go dependency is satisfied via Homebrew, there's no go executable in my path. When I run any m1-terraform-provider-helper commands, it raises a panic because there's no GOPATH:

$ m1-terraform-provider-helper activate
panic: exit status 126

goroutine 1 [running]:
github.com/kreuzwerker/m1-terraform-provider-helper/internal/app.GetCurrentGoPath()
	/home/runner/work/m1-terraform-provider-helper/m1-terraform-provider-helper/internal/app/utils.go:15 +0xf8
github.com/kreuzwerker/m1-terraform-provider-helper/internal/app.New()
	/home/runner/work/m1-terraform-provider-helper/m1-terraform-provider-helper/internal/app/app.go:48 +0x54
github.com/kreuzwerker/m1-terraform-provider-helper/cmd.activateCmd.func1(0x14000192900?, {0x1012d0702?, 0x0?, 0x0?})
	/home/runner/work/m1-terraform-provider-helper/m1-terraform-provider-helper/cmd/activate.go:14 +0x1c
github.com/spf13/cobra.(*Command).execute(0x14000192900, {0x10191cfa8, 0x0, 0x0})
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:916 +0x5c8
github.com/spf13/cobra.(*Command).ExecuteC(0x14000192300)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 +0x35c
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968
main.main()
	/home/runner/work/m1-terraform-provider-helper/m1-terraform-provider-helper/cmd/m1-terraform-provider-helper/main.go:11 +0x20

When I set an arbitrary go version or uninstall the asdf golang plugin entirely (so it falls back to /opt/homebrew/bin/go), the command runs as expected.

I can see that this has caused issues before, so even though this isn't a problem with m1-terraform-provider-helper per se, I'm wondering if it's possible to make the dependency more clear in the docs. Maybe something like what you wrote in the above-linked issue: "You need to have a go setup (because we use go to actually build the provider."

Your Environment

  • OS: macOS 13.3.1
  • m1-terraform-provider-helper version: 0.8.2

I'm happy to open a PR for this if you're interested

commented

You are totally right. We should note down in the readme, that you need to have go setup. Feel free to open a PR, that would help tremendously :)