Template v2.2.0 does not have a package available - Mac M1

By giving a try to these different answers, here is what I ran to install a Terraform 1.3.3 version that works under my Mac M1 and get rid of this error:

brew uninstall terraform
brew install tfenv
TFENV_ARCH=amd64 tfenv install 1.3.3
tfenv use 1.3.3
2 Likes

In my case helped use newer version 1.3.4

brew uninstall terraform
brew install tfenv
TFENV_ARCH=amd64 tfenv install 1.3.4
tfenv use 1.3.4
1 Like

This worked for me. Thank you!

I agree with @stuart-c - For those landing on this article in 2022/2023, please, make sure you stop using the Template Provider as it has been deprecated.

Instead, use templatefile.

working in latest version 1.3.7

brew uninstall terraform
brew install tfenv
TFENV_ARCH=amd64 tfenv install 1.3.7
tfenv use 1.3.7
1 Like

I got

$ m1-terraform-provider-helper install hashicorp/template -v v2.2.0
Getting provider data from terraform registry
Getting source code...
FATA[0001] Bash execution did not run successfully: exit status 1.
Output:
Im Moment auf keinem Branch.
Bitte geben Sie den Branch an, welchen Sie zusammenfĂźhren mĂśchten.
Siehe git-pull(1) fĂźr weitere Details.

    git pull <Remote-Repository> <Branch>
 

I fixed this by changing LANG environment:

$ LANG=en_us m1-terraform-provider-helper install hashicorp/template -v v2.2.0
Getting provider data from terraform registry
Getting source code...
Compiling...
Successfully installed hashicorp/template v2.2.0

I know this is an old post. However, I think this might be helpful for someone.

Like @lpossamai2 said in his comment above, don’t use template_file anymore and replace it with templatefile in all your modules. Then run the following:

rm -rf .terraform
rm -f .terraform.lock.hcl 
terraform init # this one will fail again, with the same error as above, but it will give you access to the state
for i in `terraform state list | grep template_file`; do terraform state rm $i; done
terraform init # this one will work now
terraform apply

Just make sure you have replaced your template_file in all your modules. Otherwise, you will hit the same problem. And check the state before you run the for loop, just in case you called any resource/module a template_file :smiley:

1 Like

ok so this is weird. just ran a terraform plan/apply Terraform 0.14.4 on my m1 Ventura Version 13.2 (22D49) and it worked even though the template provider has not been updated to dawin_arm64 : Terraform Provider Template v2.2.0 Binaries | HashiCorp Releases

worked like a charm (if you have lock files locally, delete those to avoid running into issues with this solution)

It works very well!
Thanks for sharing that!

Hi, for us any of it did not work (except crippling template_file plugin worked, but it is not really nice solution). We removed all references to template_file from code which left empty references in state file for some reason, e.g.

     {
       "module": "module.region_0",
       "mode": "data",
       "type": "template_file",
       "name": "cloudwatch_agent_update_document",
       "provider": "provider[\"registry.terraform.io/hashicorp/template\"]",
       "instances": []
     }, 

Which did not pose any issue on non-darwin_arm64 terraform binaries, but on M1 it fails. There is no clean way to fix this issue, but to go to state file and remove these empty references manually. They do not appear in terraform state list so there is really nothing to do. This seems like rather critical bug to me :frowning:

Terraform’s code normally removes these resource blocks when the instances collection becomes empty. If you are able to figure out a sequence of operations which leaves one behind like this, that would be worth a bug report.

works, thanks

This works for me as well

instead of going through the hurdles of compiling the provider, you can just use the function templatefile

replace

data "template_file" "example"{
    template = file("some_file.tpl")
    vars = {}
}

with

templatefile("some_file.tpl", {})
1 Like

Right, @magusd
The error was introduced because I used

data "template_file" "example"{
    template = file("some_file.tpl")
    vars = {}
}

Hey @AyushKumar55, though the m1-terraform-provider-helper installed the plugins to local machine, for some reason terraform did not pick it up / use it while doing a terraform init.

So doing the following worked for me,

  1. Install the provider using m1-terraform-provider-helper. It will install the provider in ~/.terraform.d/plugins/registry.terraform.io (Ref: kreuzwerker/m1-terraform-provider-helper: CLI to support with downloading and compiling terraform providers for Mac with M1 chip (github.com))
  2. Create .terraformrc file in your HOME dir (~/)
  3. Paste the following in .terraformrc file
provider_installation {
  filesystem_mirror {
    path    = "/Users/<user>/.terraform.d/plugins"
  }
  direct {
    exclude = ["terraform. Local/*/*"]
  }
}
  1. In the root’s main.tf file, add the following
terraform {
  required_providers {
    template = {
      source  = "registry.terraform.io/hashicorp/template"
      version = "2.2.0"
    }
  }
  # Other parameters...
}

If it’s main.tf.json, add the following,

"terraform": [
        # Other parameters...
        {
            "required_providers": {
                "template": {
                    "source": "registry.terraform.io/hashicorp/template",
                    "version": "2.2.0"
                }
            }
        }
    ]
  1. Do rm -rf .terraform in the project and run terraform init again.

Thank you! was looking for this <3

If you get this warning when you are trying to install kreuzwerker/taps/m1-terraform-provider-helper:

Warning: No available formula or cask with the name "kreuzwerker/taps/m1-terraform-provider-helper".

Try to do this:

  1. Clone the Repository: Clone the kreuzwerker/homebrew-taps repository to my local machine and run the following command:
git clone https://github.com/kreuzwerker/homebrew-taps.git
  1. Navigate to the Repository Folder: Change current directory to the folder containing the cloned repository and execute:
brew install --build-from-source ./m1-terraform-provider-helper.rb

This command tells Homebrew to install the package defined in the local m1-terraform-provider-helper.rb formula file. The --build-from-source flag is typically used to compile the package from source

  1. Steps to install terraform of your choice of version using Homebrew:
brew install tfenv
tfenv list_remote
tfenv install
tfenv install 1.6.6
​​tfenv use 1.6.6  

Now, while executing terraform init I faced the below error when I´m working in a MAC with M1/M2 chip in it,

Error: Incompatible provider version
│
│ Provider Terraform Registry 113 v2.2.0 does not have a
│ package available for your current platform, darwin_arm64.

Please follow the steps given below:

  1. brew install kreuzwerker/taps/m1-terraform-provider-helper
  2. m1-terraform-provider-helper activate
  3. m1-terraform-provider-helper install hashicorp/template -v v2.2.0

Thanks to @AyushKumar55 for the help.

Tried this and the steps below this one, both failed.

any other suggestions.

G