Hashes not generated, impossible to use in existing projects.
Chiyo-no-sake opened this issue · comments
On m1 mac, obviously, when I try to install a provider (say HashiCorp/google v4.11.0), it successfully installs, however I am not able to run 'terraform init' because it fails to find a checksum for the installed version in lock file.
Expected Behavior
After the installation, terraform init successfully initialise terraform.
Actual Behavior
After the installation, terraform init logs the following:
Initializing modules...
Initializing the backend...
Initializing provider plugins...
- Reusing previous version of hashicorp/archive from the dependency lock file
- Reusing previous version of hashicorp/google from the dependency lock file
- Reusing previous version of hashicorp/google-beta from the dependency lock file
- Reusing previous version of hashicorp/template from the dependency lock file
- Installing hashicorp/google v4.11.0...
- Installing hashicorp/google-beta v4.11.0...
- Installed hashicorp/google-beta v4.11.0 (signed by HashiCorp)
- Installing hashicorp/template v2.2.0...
- Installing hashicorp/archive v2.2.0...
- Installed hashicorp/archive v2.2.0 (signed by HashiCorp)
╷
│ Error: Failed to install provider
│
│ Error while installing hashicorp/google v4.11.0: the local package for registry.terraform.io/hashicorp/google 4.11.0 doesn't match any of
│ the checksums previously recorded in the dependency lock file (this might be because the available checksums are for packages targeting
│ different platforms)
╵
╷
│ Error: Failed to install provider
│
│ Error while installing hashicorp/template v2.2.0: the local package for registry.terraform.io/hashicorp/template 2.2.0 doesn't match any
│ of the checksums previously recorded in the dependency lock file (this might be because the available checksums are for packages targeting
│ different platforms)
Steps to Reproduce (including precondition)
- Have a project already configured with google provider for Google Cloud Platform, working on a normal amd64 machine.
- Clone the project on an m1 mac
- Run
m1-terraform-provider-helper install hashicorp/template -v v2.2.0
- Run
m1-terraform-provider-helper install hashicorp/google -v v4.11.0
- Run
terraform init
Your Environment
- OS: MacOS Monterey 12.2.1
- m1-terraform-provider-helper version: 0.5.1
Thank you for opening this issue!
This goes into the same direction as #34 as both have something to do with the lockfile.
I'll need some time to tackle those issues. If you could support me, that would be great! For example, posting the existing lockfile you have problems with. Or figuring out how terraform caclulates the checksum for a provider :)
@Junkern probably this can help you?
https://github.com/hashicorp/terraform/blob/main/internal/getproviders/hash.go
Thanks @tsunamaru, this is helping a lot! I already verified how to generate the lockfile hashes.
What would your ideal workflow be (also asking @Chiyo-no-sake )?
- the
install
command does automatically update the lockfile for you (and you can turn that behaviour off with a flag) - the
install
command updates the lockfile if you provide an additional flag - I introduce an additional
upgrade-lockfile
command which updates the lockfile (and theinstall
command tells you to run theupgrade-lockfile
command in case it there is a lockfile)
Since we're executing install
command only once to compile provider binary and then just reusing it in all other lockfiles, my vote is going for third option -- upgrade-lockfile
command.
@tsunamaru @Chiyo-no-sake m1-terraform-provider-helper lockfile upgrade
is now released with v0.7.0