Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seeing "The filename or extension is too long" when "terragrunt plan" is executed in Windows

Executing "terragrunt plan" from Visual Studio code gives the below error in Windows 10:

Running command: 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

Initializing the backend...

Successfully configured the backend "s3"! Terraform will automatically use this backend unless the backend configuration changes.

Initializing provider plugins...

  • Finding hashicorp/aws versions matching "~> 3.36.0"...
  • Installing hashicorp/aws v3.36.0...

Error: Failed to install provider

Error while installing hashicorp/aws v3.36.0: mkdir .terraform/plugins/registry.terraform.io/hashicorp/aws/3.36.0/windows_amd64: The filename or extension is too long.

[terragrunt] 2021/05/19 15:39:20 Hit multiple errors: exit status 1

like image 438
Vamshee Akula Avatar asked Oct 17 '25 02:10

Vamshee Akula


2 Answers

The proper fix is here:

  1. Start Git Bash as Administrator
  2. Run command git config --system core.longpaths true

How to fix "Filename too long error" during git clone

like image 127
Rexxo Avatar answered Oct 19 '25 01:10

Rexxo


Thanks Rubens for suggesting using TERRAGRUNT_DOWNLOAD environment variable. I'm able to work around this problem.

Here are the complete steps in terragrunt:

  1. from cmd, set TERRAGRUNT_DOWNLOAD and call init:
set TERRAGRUNT_DOWNLOAD=C:\\.terragrunt-cache

terragrunt init
  1. Then copy or move C:\\.terragrunt-cache content to the .terragrunt-cache in my project (better clean up the folder first)

  2. from cmd, unset TERRAGRUNT_DOWNLOAD and call apply

set TERRAGRUNT_DOWNLOAD=

terragrunt apply
like image 28
pigtail hello Avatar answered Oct 19 '25 01:10

pigtail hello