简体   繁体   English

Apple M1 上的 Terraform 间歇性错误

[英]Terraform Intermittent error on Apple's M1

When I run terraform plan , I expect to see a plan but instead I get当我运行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...

System is: arm64 m1 - Monterey - TFEnv - Terraform 1.1.9系统是:arm64 m1 - Monterey - TFEnv - Terraform 1.1.9

Solution解决方案

Explanation解释

  1. An issue in Go runtime running amd64 M1 through Apple's Rosetta通过 Apple 的 Rosetta 运行 amd64 M1 的 Go 运行时出现问题
  2. TFenv installed the amd64 version of Terraform instead of arm64. TFenv安装了 amd64 版本的 Terraform 而不是 arm64。

Patch修补

Set the variable GODEBUG=asyncpreemptoff=1 by prepending it to the front of your terraform or adding it to your bash profile.设置变量GODEBUG=asyncpreemptoff=1通过将其添加到 terraform 的前面或将其添加到 bash 配置文件中。

Fix使固定

Make sure you are running the right build for your system.确保您正在为您的系统运行正确的构建。

➜ terraform version
Terraform v1.1.9
on darwin_arm64

If you are on an M1 and see darwin_amd64 when you run terraform version , try installing Terraform again.如果您在 M1 上并在运行terraform version时看到darwin_amd64 ,请尝试再次安装 Terraform。

With TFenv使用 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 https://github.com/hashicorp/terraform-provider-aws/issues/23850
  2. https://yaleman.org/post/2021/2021-01-01-apple-m1-terraform-and-golang/ https://yaleman.org/post/2021/2021-01-01-apple-m1-terraform-and-golang/

只需将TFENV_ARCH设置为 arm64 并使用tfenv再次重新安装 Terraform

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM