Installing old terraform versions fails on arm64 Mac
DanielWeintraub opened this issue · comments
When I try to install Terraform 0.14.10 it fails:
Downloading terraform version 0.14.10 from https://releases.hashicorp.com/terraform/0.14.10/terraform_0.14.10_darwin_arm.zip
Error: terraform version 0.14.10 not found
There isn't an arm release of this version so naturally the download fails, but if it downloaded the amd64 version I could run it under Rosetta 2.
I now see the README describes support for an environmental variable to work around this problem, but perhaps it shouldn't require finding this repo and reading that to make it work.
I've been meaning to add help scripts to output information on the plugin configuration options via the CLI, which should help with this problem.
I suppose that's not very visible in the moment, though, since it requires running a separate command - do you think it would be worth adding some extra help text in the error handling here to suggest that the user may want to investigate the plugin's configuration options?
It probably would have helped in my case, but maybe that's just because I was new to the software and plugin config via environmental variables is particularly hard to discover.
Hey everyone,
I had racked my brains and figured it out when reading the function and using a set -x
To works:
ASDF_HASHICORP_OVERWRITE_ARCH_terraform=amd64 asdf install terraform x.x.x
Not Works:
ASDF_HASHICORP_OVERWRITE_ARCH_TERRAFORM=amd64 asdf install terraform 0.14.10
ASDF_HASHICORP_OVERWRITE_ARCH=amd64 asdf install terraform 0.14.10
As mentioned when defining only the variable ASDF_HASHICORP_OVERWRITE_ARCH it is ignored and it is always false due to the function
$HOME/.asdf/plugins/terraform/bin/install
get_arch() {
local -r machine="$(uname -m)"
local -r upper_toolname=$(echo "${toolname}" | tr '[:upper:]' '[:lower:]')
local -r tool_specific_arch_override="ASDF_HASHICORP_OVERWRITE_ARCH_${upper_toolname}"
OVERWRITE_ARCH_TOOL=${!tool_specific_arch_override:-"false"}
OVERWRITE_ARCH=${OVERWRITE_ARCH_TOOL:-$(ASDF_HASHICORP_OVERWRITE_ARCH)}
if [[ $OVERWRITE_ARCH != "false" ]]; then
echo "$OVERWRITE_ARCH"
elif [[ $machine == "arm64" ]] || [[ $machine == "aarch64" ]]; then
echo "arm64"
elif [[ $machine == *"arm"* ]] || [[ $machine == *"aarch"* ]]; then
echo "arm"
elif [[ $machine == *"386"* ]]; then
echo "386"
else
echo "amd64"
fi
}
Only ASDF_HASHICORP_OVERWRITE_ARCH_TERRAFORM=amd64 asdf install terraform 0.12.31
worked for me. @mayconritzmann Thanks for the hint
FWIW you can also run asdf
under Rosetta 2 using arch -x86_64 asdf install terraform 0.12.31
for the same basic effect.
Only
ASDF_HASHICORP_OVERWRITE_ARCH_TERRAFORM=amd64 asdf install terraform 0.12.31
worked for me. @mayconritzmann Thanks for the hint
This totally works, thank you!
Incase you using terraform with terragrunt, you can install it like;
ASDF_HASHICORP_OVERWRITE_ARCH_TERRAFORM=amd64 asdf install terraform `version`
ASDF_TERRAGRUNT_OVERWRITE_ARCH=amd64 asdf install terragrunt `version`