Automatic Provider Cache Dir is an experimental feature of Terragrunt that automatically configures OpenTofu’s native provider caching mechanism by setting the TF_PLUGIN_CACHE_DIR
environment variable. This enables efficient provider caching without the need to manually configure provider cache directories or use Terragrunt’s provider cache server.
When the Auto Provider Cache Dir experiment is enabled, Terragrunt will automatically configure OpenTofu to use a shared provider cache directory, which provides several benefits:
The Automatic Provider Cache Dir feature has specific requirements:
Since this is an experimental feature, it must be explicitly enabled using the --experiment
flag:
terragrunt run --all apply --experiment auto-provider-cache-dir
Or with environment variables:
TG_EXPERIMENT='auto-provider-cache-dir' \
terragrunt run --all apply
When enabled, Terragrunt automatically:
The default provider cache directory is located at:
$HOME/.terragrunt-cache/providers
on Unix systems$HOME/Library/Caches/terragrunt/providers
on macOS%LocalAppData%\terragrunt\providers
on WindowsYou can customize the provider cache directory using the --provider-cache-dir
flag:
terragrunt apply \
--experiment auto-provider-cache-dir \
--provider-cache-dir /custom/path/to/cache
Or with environment variables:
TG_EXPERIMENT='auto-provider-cache-dir' \
TG_PROVIDER_CACHE_DIR='/custom/path/to/cache' \
terragrunt apply
Even when the experiment is enabled, you can selectively disable the feature for specific runs using the --no-auto-provider-cache-dir
flag:
terragrunt run --all apply \
--experiment auto-provider-cache-dir \
--no-auto-provider-cache-dir
This is particularly useful when:
Terragrunt also provides a Provider Cache Server feature. Here’s when to use each:
Use Auto Provider Cache Dir when:
Use Provider Cache Server when:
If the feature doesn’t seem to be working:
TF_PLUGIN_CACHE_DIR
is not already set by another toolYou can enable debug logging to see more information:
terragrunt apply --log-level debug --experiment auto-provider-cache-dir
This feature is currently experimental and may change in future versions. Based on community feedback and testing, it may be stabilized and enabled by default in future releases.
For the latest status and to provide feedback, see the auto-provider-cache-dir experiment documentation.