Create a new control file with the name .terraformrc or terraform.rc in your profile folder.
Add the following lines:
plugin_cache_dir = "$HOME/.terraform.d/plugin-cache"
Create the folder .terraform.d/plugin-cache in your profile folder.
The providers will be downloaded to the cache folder when you run terraform init
.
If you don’t want to create the control file in the profile folder. Alternative is to create an environment variable.
export TF_PLUGIN_CACHE_DIR="$HOME/.terraform.d/plugin-cache"