terraform-plugin-docs
terraform-plugin-docs copied to clipboard
Consider Warning/Error With Mismatched Terraform Architecture
Seems like right now tfplugindocs generate got hardcoded - plugins/registry.terraform.io/hashicorp/ for the providerPath, but in case of locally developed provider it's not a case.
$ tfplugindocs generate
rendering website for provider "terraform-provider-xxx" (as "terraform-provider-xxx")
exporting schema from Terraform
compiling provider "xxx"
using Terraform CLI binary from PATH if available, otherwise downloading latest Terraform CLI binary
running terraform init
Error executing command: unable to generate website: exit status 1
Error: Incompatible provider version
Provider registry.terraform.io/hashicorp/xxx v0.0.1 does not have a
package available for your current platform, windows_386.
Provider releases are separate from Terraform CLI releases, so not all
providers are available for all platforms. Other versions of this provider
may have different platforms supported.
running into this same issue with an m1:
tfplugindocs generate --ignore-deprecated true
rendering website for provider "terraform-provider-consul" (as "terraform-provider-consul")
copying any existing content to tmp dir
exporting schema from Terraform
compiling provider "consul"
using Terraform CLI binary from PATH if available, otherwise downloading latest Terraform CLI binary
running terraform init
Error executing command: unable to generate website: exit status 1
Error: Incompatible provider version
Provider registry.terraform.io/hashicorp/consul v0.0.1 does not have a
package available for your current platform, darwin_arm64.
Provider releases are separate from Terraform CLI releases, so not all
providers are available for all platforms. Other versions of this provider
may have different platforms supported
Came across this thread with some suggestions which did not work for me: https://discuss.hashicorp.com/t/template-v2-2-0-does-not-have-a-package-available-mac-m1/35099/7
Hi all 👋🏻 , thanks for reporting the issue and sorry you're running into trouble here.
For both reports, I think the reported error message might be a red-herring for a different bug, but will need to dig into what's going on first.
Re: @gerbil
I think the hard coded path you're referencing is this. When plugin docs builds your provider, it's just using this path for the temporary output binary when it runs go build
. It is definitely named incorrectly and should be updated, but shouldn't cause a problem for running the doc generator locally.
I have a non-hashicorp sandbox provider here that I was able to generate docs for, running tfplugindocs generate
in the root of the repo.
Re: @roncodingenthusiast
Hmm 🤔, I'm not able to reproduce this error in the consul provider. Here is my reproduction attempt where I was able to successfully generate the docs from the master
branch using v0.16.0 plugin-docs for my M1:
Run on Consul provider
$ git clone [email protected]:hashicorp/terraform-provider-consul.git
$ cd terraform-provider-consul
$ tfplugindocs --version
tfplugindocs Version 0.16.0 from commit c4e6bffee6d161b16b31a261459ea7f94060f7e8
$ tfplugindocs generate --ignore-deprecated true
rendering website for provider "terraform-provider-consul" (as "terraform-provider-consul")
copying any existing content to tmp dir
exporting schema from Terraform
compiling provider "consul"
using Terraform CLI binary from PATH if available, otherwise downloading latest Terraform CLI binary
running terraform init
getting provider schema
rendering missing docs
generating missing resource content
resource "consul_autopilot_config" static file exists, skipping
resource "consul_key_prefix" static file exists, skipping
resource "consul_keys" static file exists, skipping
resource "consul_namespace" static file exists, skipping
generating template for "consul_peering"
generating template for "consul_peering_token"
resource "consul_acl_auth_method" template exists, skipping
resource "consul_acl_role" static file exists, skipping
resource "consul_acl_token" static file exists, skipping
resource "consul_acl_token_role_attachment" static file exists, skipping
resource "consul_namespace_policy_attachment" static file exists, skipping
resource "consul_namespace_role_attachment" static file exists, skipping
resource "consul_acl_binding_rule" static file exists, skipping
resource "consul_acl_policy" static file exists, skipping
resource "consul_acl_token_policy_attachment" static file exists, skipping
resource "consul_admin_partition" static file exists, skipping
resource "consul_config_entry" static file exists, skipping
generating template for "consul_prepared_query"
resource "consul_service" template exists, skipping
generating template for "consul_certificate_authority"
resource "consul_network_area" static file exists, skipping
resource "consul_node" static file exists, skipping
generating missing data source content
resource "consul_datacenters" static file exists, skipping
resource "consul_network_area_members" static file exists, skipping
resource "consul_network_segments" static file exists, skipping
generating template for "consul_peering"
resource "consul_acl_token" static file exists, skipping
resource "consul_agent_config" static file exists, skipping
generating template for "consul_config_entry"
resource "consul_services" static file exists, skipping
resource "consul_acl_role" static file exists, skipping
resource "consul_acl_token_secret_id" static file exists, skipping
resource "consul_autopilot_health" static file exists, skipping
resource "consul_nodes" static file exists, skipping
generating template for "consul_peerings"
resource "consul_service_health" static file exists, skipping
resource "consul_acl_auth_method" static file exists, skipping
resource "consul_key_prefix" static file exists, skipping
resource "consul_keys" static file exists, skipping
resource "consul_service" static file exists, skipping
resource "consul_acl_policy" static file exists, skipping
generating missing provider content
provider "terraform-provider-consul" template exists, skipping
rendering static website
cleaning rendered website dir
removing directory: "data-sources"
removing directory: "guides"
removing file: "index.md"
removing directory: "resources"
rendering templated website to static markdown
copying non-template file: "data-sources/acl_auth_method.md"
copying non-template file: "data-sources/acl_policy.md"
copying non-template file: "data-sources/acl_role.md"
copying non-template file: "data-sources/acl_token.md"
copying non-template file: "data-sources/acl_token_secret_id.md"
copying non-template file: "data-sources/agent_config.md"
copying non-template file: "data-sources/agent_self.md"
copying non-template file: "data-sources/autopilot_health.md"
rendering "data-sources/config_entry.md.tmpl"
copying non-template file: "data-sources/datacenters.md"
copying non-template file: "data-sources/key_prefix.md"
copying non-template file: "data-sources/keys.md"
copying non-template file: "data-sources/network_area_members.md"
copying non-template file: "data-sources/network_segments.md"
copying non-template file: "data-sources/nodes.md"
rendering "data-sources/peering.md.tmpl"
rendering "data-sources/peerings.md.tmpl"
copying non-template file: "data-sources/service.md"
copying non-template file: "data-sources/service_health.md"
copying non-template file: "data-sources/services.md"
copying non-template file: "guides/upgrading.md"
rendering "index.md.tmpl"
rendering "resources/acl_auth_method.md.tmpl"
copying non-template file: "resources/acl_binding_rule.md"
copying non-template file: "resources/acl_policy.md"
copying non-template file: "resources/acl_role.md"
copying non-template file: "resources/acl_token.md"
copying non-template file: "resources/acl_token_policy_attachment.md"
copying non-template file: "resources/acl_token_role_attachment.md"
copying non-template file: "resources/admin_partition.md"
copying non-template file: "resources/agent_service.md"
copying non-template file: "resources/autopilot_config.md"
copying non-template file: "resources/catalog_entry.md"
rendering "resources/certificate_authority.md.tmpl"
copying non-template file: "resources/config_entry.md"
copying non-template file: "resources/intention.md"
copying non-template file: "resources/key_prefix.md"
copying non-template file: "resources/keys.md"
copying non-template file: "resources/license.md"
copying non-template file: "resources/namespace.md"
copying non-template file: "resources/namespace_policy_attachment.md"
copying non-template file: "resources/namespace_role_attachment.md"
copying non-template file: "resources/network_area.md"
copying non-template file: "resources/node.md"
rendering "resources/peering.md.tmpl"
rendering "resources/peering_token.md.tmpl"
rendering "resources/prepared_query.md.tmpl"
rendering "resources/service.md.tmpl"
Question for both
Do either of you have GOOS
or GOARCH
environment variables set while running tfplugindocs generate
? Wondering if cross-compilation could be a potentially cause here.
$ go env GOOS GOARCH
darwin
amd64
#299 will add some additional context to generate
command errors, which might be helpful in this case. As an offhand workaround, that change set also adds a provider-schema
flag which can be used to skip building the provider and calling Terraform CLI, if you already have the provider schema JSON available from calling terraform providers schema -json
. 👍
I am running into the same issue. I am trying to generate plugin documentation locally without having the provider published to the registry.
uname -a
proves that I've got a darwin arm64 machine Darwin ** arm64
Here are my GOENV
and GOARCH
environment variables:
❯ echo "$GOOS $GOARCH" darwin arm64
Why is tfplugindocs using the incorrect architecture?
Related: #317
@moritzkohl do/did you happen to have tfplugindocs
amd64 binary installed? You can confirm with the file
command/builtin, e.g.
$ which tfplugindocs
/Users/bflad/go/bin/tfplugindocs
$ file /Users/bflad/go/bin/tfplugindocs
/Users/bflad/go/bin/tfplugindocs: Mach-O 64-bit executable arm64
Hey @bflad. I have the same version installed as you do:
❯ which tfplugindocs
/Users/moritzkohl/go/bin/tfplugindocs
❯ file /Users/moritzkohl/go/bin/tfplugindocs
/Users/moritzkohl/go/bin/tfplugindocs: Mach-O 64-bit executable arm64
@moritzkohl how about the terraform
command? Also, if you have the error messaging, that would be helpful, thanks!
Personally I have only been able to reproduce this by having a mismatch in binary architecture between Terraform and tfplugindocs
. In general for anyone here: if you are running on macOS with "Apple Silicon" hardware (M1, M2, M3, etc.), you'll want to ensure both Terraform and tfplugindocs
are the arm64 architecture, not amd64 (x86_64). If you are running on 64-bit Linux/Windows with Intel or AMD CPUs, ensure both Terraform and tfplugindocs
are the amd64 (x86_64) architecture.
@bflad Thank you so much for this comment. I've been chasing this for a while, and this solved it for me. Turns out my asdf installation of terraform was stilling using the amd64 binary for terraform.
For others seeing this terraform version
will tell you the architecture that it was compiled for.
Apparently I was facing a similar issue as @sudermanjr. My tfenv
installation used for different project terraform versions seemed to install the terraform AMD version when the TFENV_ARCH
environment was for some reason set to amd64
on my machine.
Setting it to arm64
in my .zshrc
seemed to resolve the problem.
Thanks alot! @bflad
Thanks, all! Glad that we could find the issue.
Now for the fun part of better documentation and considerations for how to help folks either be notified or avoid this problem in the future. As a top of head thought, I wonder if we could compare terraform version -json
output with fmt.Sprintf("%s_%s", runtime.GOOS, runtime.GOARCH)
to either display some sort of warning text or outright error when there is a mismatch and when Terraform commands must be called. In either case though, that messaging could mention the mismatching architectures could cause issues like these. 👍
One additional note about my above thought with terraform version -json
-- the output is not stable until 0.15/1.0. The README documentation makes no mention of Terraform requirements currently, but I think 1.0+ is quite reasonable as this only affects a provider developer workflows, not practitioner workflows.