I tried to install terraform in Ubuntu desktop but I am getting error:
bash: /usr/local/bin/terraform: cannot execute binary file: Exec format error"
The same steps working for cloud servers.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communitySteps to install terraform on Ubuntu / Ubuntu cloud server :
Install unzip
sudo apt-get install unzip
Confirm the latest version number on the terraform website:
https://www.terraform.io/downloads.html
Download latest version of the terraform (substituting newer version number if needed)
wget https://releases.hashicorp.com/terraform/1.0.7/terraform_1.0.7_linux_amd64.zip
Extract the downloaded file archive
unzip terraform_1.0.7_linux_amd64.zip
Move the executable into a directory searched for executables
sudo mv terraform /usr/local/bin/
Run it
terraform --version
sudo install terraform /usr/local/bin/
is more reliable, it ensures ownership and permissions are correct.
sudo install
actually add here? I'm asking this because I am getting "install: cannot stat 'terraform': No such file or directory" when trying to run it, and can't get it to work as intended. Feeling awkward about not using this command ever before...
Mar 13, 2019 at 5:19
install
instead of` mv
, otherwise if you call it after mv
there will no terraform file in your current directory, and you will get an error.
If you’re running Ubuntu plus snap installed, just call:
sudo snap install terraform --classic
/snap/terraform/216/bin/terraform apply
. But I just use terraform apply
and let PATH find /snap/bin/terraform
, the binary cannot use my ssh-agent.
What about using Terraform official deb repository, you can than install and update Terraform using apt
.
https://www.terraform.io/docs/cli/install/apt.html#repository-configuration
Like this:
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=$(dpkg --print-architecture)] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt update
sudo apt install terraform
My one-liner to install the latest version:
sudo echo ; zcat <( CURRR_VER=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version') ; curl -q "https://releases.hashicorp.com/terraform/${CURRR_VER#?}/terraform_${CURRR_VER#?}_linux_amd64.zip" ) | sudo tee /usr/local/bin/terraform > /dev/null ; sudo chmod +x /usr/local/bin/terraform
Using the line from https://github.com/hashicorp/terraform/issues/9803#issuecomment-257903082
This error occured when you try run 64 bit exec file on 32 bit system. Check your system:
uname -a
x86_64 or i686 mean 64 or 32 bit accordinary.
You can also use 3 different tools that can help you to install and use specific versions of Terraform (similar to nvm, pyenv, rbenv, rustup tools):
tfswitch
: https://github.com/warrensbox/terraform-switcher/cloudposse/tfenv
: https://github.com/cloudposse/tfenvtfutils/tfenv
: https://github.com/tfutils/tfenv/I like the first one as it was made in golang and a snap
package is available (but not currently in latest version https://github.com/warrensbox/terraform-switcher/issues/126).
The most popular is tfutils/tfenv/
and that's the one that I'm using right now.
I referred to The Official Terraform Website to install Terraform for Ubuntu and Debian.
Ensure that your system is up to date, and you have the gnupg, software-properties-common, and curl packages installed. You will use these packages to verify HashiCorp's GPG signature, and install HashiCorp's Debian package repository:
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl
Add the HashiCorp GPG key:
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
Add the official HashiCorp Linux repository:
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
Update to add the repository, and install the Terraform CLI:
sudo apt-get update && sudo apt-get install terraform
Check if Terraform is successfully installed:
terraform -v
terraform version
gives me the old version, not sure what I'm doing wrong?
sudo apt-get install terraform
then run the command sudo apt-get update
then sudo apt-get upgrade
will help you to get the suitable version of the teraform into the simulated hardware that was fetched from the Ubuntu install or any of the Linux version installed into your system.