在苹果M1上,Terraform出现间歇性错误。

5
当我运行 terraform plan 时,我期望看到一个计划,但实际上我得到了:
│ 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 registry.terraform.io/hashicorp/aws: failed to
│ instantiate provider "registry.terraform.io/hashicorp/aws" to obtain schema: Unrecognized remote plugin message:
│
│ This usually means that the plugin is either invalid or simply
│ needs to be recompiled to support the latest protocol...

系统环境: arm64 m1 - Monterey - TFEnv - Terraform 1.1.9

2个回答

10

解决方案

说明

  1. Go运行时在通过苹果的Rosetta运行amd64 M1时出现问题。
  2. TFenv 安装了amd64版本的Terraform而不是arm64。

补丁

通过将变量 GODEBUG=asyncpreemptoff=1 添加到terraform前面或添加到您的bash配置文件中,来设置该变量。

修复

确保您正在运行适合您的系统的正确版本。

➜ terraform version
Terraform v1.1.9
on darwin_arm64

如果您在 M1 上运行 terraform version 时看到 darwin_amd64,请尝试重新安装 Terraform。
使用 TFenv。
TFENV_ARCH=arm64 tfenv install 1.2.4
tfenv use 1.2.4

Details

  1. https://github.com/hashicorp/terraform-provider-aws/issues/23850
  2. https://yaleman.org/post/2021/2021-01-01-apple-m1-terraform-and-golang/

1
干杯!在我的 M1 Mac Monterey 上指定 TFENV_ARCH 标志解决了我的问题。 - DanH

0

只需将环境变量TFENV_ARCH设置为arm64,然后再使用tfenv重新安装Terraform即可。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接