# Using custom provider gives "exec format error" error

**URL:** <https://discuss.hashicorp.com/t/using-custom-provider-gives-exec-format-error-error/58741>\
**Category:** Terraform\
**Created:** [October 3, 2023, 3:30pm UTC](https://discuss.hashicorp.com/t/using-custom-provider-gives-exec-format-error-error/58741 "2023-10-03T15:30:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shawnchapla-8451](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/shawnchapla-8451/32/35274_2.png) [@shawnchapla-8451](https://discuss.hashicorp.com/u/shawnchapla-8451)\
**Post date:** [October 3, 2023, 3:30pm UTC](https://discuss.hashicorp.com/t/using-custom-provider-gives-exec-format-error-error/58741/1 "2023-10-03T15:30:42Z")

</div>

I’m trying to modify an open source provider for use inside my organization. I’ve built the binary for both darwin and linux amd64 provider platforms, and have uploaded them to our private TFC registry. When I then use Terraform CLI on either of these platforms, the provider is downloaded with “terraform init”, but I get the same error when using “terraform plan”:

```auto
│ Error: Failed to load plugin schemas
│ 
│ Error while loading schemas for plugin components: Failed to obtain provider schema: Could not load the schema for provider app.terraform.io/<org>/kong: failed to instantiate provider
│ "app.terraform.io/<org>/kong" to obtain schema: fork/exec .terraform/providers/app.terraform.io/<org>/kong/1.0.0/darwin_amd64/terraform-provider-kong_v1.0.0: exec format error..

```

I get the same error trying it on Ubuntu. I built the binary with the same Go arguments on each platform, based on an online post I saw from someone else getting the same error:

`CGO_ENABLED=0 GOOS=<OS> GOARCH=amd64 go build -a -ldflags '-w -extldflags "-static"' -o terraform-provider-kong ./kong`

When I look at the binary downloaded into the .terraform directory structure, they appear to be for the right platform (so I didn’t mix up the Zip files I uploaded to the registry), e.g. on macOS:

```auto
!<arch>
__.PKGDEF 0 0 0 644 184111 `
go object darwin amd64 go1.19.13 X:regabiwrappers,regabiargs

```

Any suggestions on how to debug this?

---

<div class="post-metadata">

**Author:** ![shawnchapla-8451](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/shawnchapla-8451/32/35274_2.png) [@shawnchapla-8451](https://discuss.hashicorp.com/u/shawnchapla-8451)\
**Post date:** [October 3, 2023, 4:37pm UTC](https://discuss.hashicorp.com/t/using-custom-provider-gives-exec-format-error-error/58741/2 "2023-10-03T16:37:22Z")

</div>

Found I was compiling it incorrectly. Reverted to a simple `go build -o <binary name> .` and that seemed to resolve it.
