terragrunt: Error: Required plugins are not installed (terraform 1.1)
After upgrading terraform to version 1.1 I’ve got error Error: Required plugins are not installed for every terragrunt command.
Configurations
terraform {
extra_arguments "cache" {
commands = [
"init",
"apply",
"refresh",
"import",
"plan",
"taint",
"untaint"
]
env_vars = {
TF_PLUGIN_CACHE_DIR = "$HOME/.terraform.d/plugin-cache"
}
}
}
and
$ cat ~/.terraformrc
plugin_cache_dir = "$HOME/.terraform.d/plugin-cache"
do not make any effect.
More outputs:
$ terragrunt apply
╷
│ Error: Required plugins are not installed
│
│ The installed provider plugins are not consistent with the packages
│ selected in the dependency lock file:
│ - registry.terraform.io/cloudflare/cloudflare: there is no package for registry.terraform.io/cloudflare/cloudflare 2.23.0 cached in .terraform/providers
│ - registry.terraform.io/hashicorp/aws: there is no package for registry.terraform.io/hashicorp/aws 3.49.0 cached in .terraform/providers
│ - registry.terraform.io/hashicorp/helm: there is no package for registry.terraform.io/hashicorp/helm 2.2.0 cached in .terraform/providers
│ - registry.terraform.io/hashicorp/kubernetes: there is no package for registry.terraform.io/hashicorp/kubernetes 2.3.2 cached in .terraform/providers
│
│ Terraform uses external plugins to integrate with a variety of different
│ infrastructure services. To download the plugins required for this
│ configuration, run:
│ terraform init
╵
ERRO[0004] exit status 1
$ terragrunt init
╷
│ Error: Required plugins are not installed
│
│ The installed provider plugins are not consistent with the packages
│ selected in the dependency lock file:
│ - registry.terraform.io/hashicorp/aws: there is no package for registry.terraform.io/hashicorp/aws 3.49.0 cached in .terraform/providers
│ - registry.terraform.io/hashicorp/helm: there is no package for registry.terraform.io/hashicorp/helm 2.2.0 cached in .terraform/providers
│ - registry.terraform.io/hashicorp/kubernetes: there is no package for registry.terraform.io/hashicorp/kubernetes 2.3.2 cached in .terraform/providers
│ - registry.terraform.io/cloudflare/cloudflare: there is no package for registry.terraform.io/cloudflare/cloudflare 2.23.0 cached in .terraform/providers
│
│ Terraform uses external plugins to integrate with a variety of different
│ infrastructure services. To download the plugins required for this
│ configuration, run:
│ terraform init
╵
ERRO[0004] exit status 1
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 28
- Comments: 30 (1 by maintainers)
@Sebor can you try deleting the
.terraform.lock.hclfile? I was able to reproduce and then solve by removing the lock file.If you have dependencies, try to clear and init or upgrade the dependencies first. This step solved my issue.
Can confirm removing the lock files solves it, but you need to do it on the current module and any it depends on.
I’ve been using
find . -name '.terragrunt-cache' | xargs rm -rfto do it more automatically.I kept running into this error for a particular directory. I tried deleting the terraform lock files but that wasn’t helping. Finally I found if I deleted
./.terragrunt-cachefrom where I was executing terragrunt, it finally worked without error for me.Sorry, I forgot to mention it. OS: MacOS 12.1 Terragrunt: v0.35.16
We are facing the same issue after upgrading TF from
1.1.3to1.4.2. On Arch Linux with terragrunt version0.43.2.Neither deleting lock and/or cache files nor deleting plugin-cache nor setting the optimization flag yield any meaningful improvement.
So far the only way is to delete the files and re-run and hope it works.
And it takes a long time to fail. 2 minutes for a modulke with 3 dependencies.
tl;dr: try setting
disable_dependency_optimizationtotruein yourremoteblock.My team and I manage a monorepo with 300+ root modules in it, all as terragrunt modules. We have run into this problem hundreds of times per day, every day. Here are some of the things we’ve learned:
We have rarely or never seen this issue when we run
terragrunton our local machines, we only see the issue when it’s run in our GitHub Actions workflow. I’m guessing it’s because on our locals we cache our providers long-term in$HOME/.terraform.d/plugin-cache.Yesterday we turned on debug logging for both terragrunt and terraform, to see what a failure and a success look like next to each other. We’ve only done some spot checking, but we realized something: We almost always see the “Required plugins not installed” error in a root module that has more than 1
dependencyblock! This led us to believe it was some kind of race condition in the way terragrunt handles dependencies.Another factor we’re considering is that only 10% of our terragrunt modules are the kind with
.tffiles in them. The vast majority of our roots use aterraformblock interragrunt.hcl. I’m not sure how this might make a difference to terragrunt’s execution.One of my teammates looked into the terragrunt docs to see what they could find about dependencies, and they found a flag we could set in our
remoteblock to disable dependency optimization. Settingdisable_dependency_optimizationtotruein ourremoteblock seems to have made the problem go away! We’re still investigating, but this is a promising lead for us.I’ll be back if we find out more in our travels.
We have this issue randomly on our build server, it’s quite frequent. It only seems to affect modules with terragrunt dependencies on others. A rebuild generally fixes it.
I’ve came across this issue a few times (also apple silicon) - my solution was clearing
.terragrunt-cacheand/or.terraform.lock.hclin dependency block paths. It wasn’t my direct module causing the issue but work I had init/plan/applied days ago where there has been a provider update then causing issues when its fetching output from the dependency.My team has been running up against this problem constantly for at least a month. We’ve updated our lockfiles with
terragrunt init -upgrade, but haven’t tried deleting them yet. For folks that have had luck with the deletion route: can I reinstate the lockfile after I get a clean plan/apply? I ask because we like to have our lockfiles checked in to git, to ensure that our Actions runner will always use the same set of providers.