在Windows中执行“terragrunt plan”时看到“文件名或扩展名太长”

问题描述 投票:0回答:5

在 Windows 10 中从 Visual Studio 代码执行“terragrunt plan”会出现以下错误:

运行命令:terraform init -backend-config=region=eu-west-2 -backend-config=bucket=bucket-name" -backend-config=dynamodb_table=lock-table -backend-config=encrypt=true -backend- config=key=ec2/terraform.tfstate

正在初始化后端...

后端“s3”配置成功! Terraform 会自动 除非后端配置发生变化,否则使用此后端。

正在初始化提供商插件...

  • 正在查找与“~> 3.36.0”匹配的 hashicorp/aws 版本...
  • 安装 hashicorp/aws v3.36.0...

错误:无法安装提供程序

安装 hashicorp/aws v3.36.0 时出错:mkdir .terraform/plugins/registry.terraform.io/hashicorp/aws/3.36.0/windows_amd64: 文件名或扩展名太长。

[terragrunt] 2021/05/19 15:39:20 遇到多个错误: 退出状态 1

terraform terragrunt hashicorp
5个回答
3
投票

感谢 Rubens 建议使用

TERRAGRUNT_DOWNLOAD
环境变量。我可以解决这个问题。

以下是 terragrunt 中的完整步骤:

  1. 在 cmd 中,设置 TERRAGRUNT_DOWNLOAD 并调用 init:
set TERRAGRUNT_DOWNLOAD=C:\\.terragrunt-cache

terragrunt init
  1. 然后将

    C:\\.terragrunt-cache
    内容复制或移动到我项目中的
    .terragrunt-cache
    (最好先清理文件夹)

  2. 从 cmd 取消设置 TERRAGRUNT_DOWNLOAD 并调用 apply

set TERRAGRUNT_DOWNLOAD=

terragrunt apply

2
投票

正确的修复方法在这里:

  1. 以管理员身份启动 Git Bash
  2. 运行命令
    git config --system core.longpaths true

如何修复 git 克隆期间的“文件名太长错误”


1
投票

今天遇到了这个问题,我通过创建一个

TERRAGRUNT_DOWNLOAD
环境变量解决了。

我将值设置为

TERRAGRUNT_DOWNLOAD=C:\.terragrunt-cache

从这个问题得到了这个解决方案 https://github.com/gruntwork-io/terragrunt/issues/581#issuecomment-460051767


0
投票

如果

Terragruntis
正在使用
Git for Windows
,你可以用

解决它

以管理员身份在命令提示符中运行

git config --system core.longpaths true

查看更多: https://stackoverflow.com/a/22575737/14081474


-1
投票

我在 terraform init 上遇到了类似的问题。我安装了最新版本的 terraform 并且它得到了解决。

© www.soinside.com 2019 - 2024. All rights reserved.