Failed to instantiate provider "local" to obtain schema

Hi folks, I’ve upgraded my Terraform client to the latest version available from brew:

$ terraform version
Terraform v0.12.7
+ provider.aws v2.12.0
+ provider.local v1.1.0

Our Terraform project was upgraded to 0.12 sometime ago by a former colleague (no idea how it was tested after upgrading). Now, when I run terraform plan in the project, I get this error:

Error: Failed to instantiate provider “local” to obtain schema: Incompatible API version with plugin. Plugin version: 4, Client versions: [5]

Our project configs include four resource "local_file" sections, but when I comment them out I get the same error. Any suggestions on how I can fix this greatly appreciated!

Here is some DEBUG level log output from terraform plan

2019-08-23T16:07:53.530-0700 [INFO]  plugin: configuring client automatic mTLS
2019-08-23T16:07:53.558-0700 [DEBUG] plugin: starting plugin: path=/Users/miketitus/Workspace/git/spelljammer/clusters/dev-spelljammer/.terraform/plugins/darwin_amd64/terraform-provider-local_v1.1.0_x4 args=[/Users/miketitus/Workspace/git/spelljammer/clusters/dev-spelljammer/.terraform/plugins/darwin_amd64/terraform-provider-local_v1.1.0_x4]
2019-08-23T16:07:53.561-0700 [DEBUG] plugin: plugin started: path=/Users/miketitus/Workspace/git/spelljammer/clusters/dev-spelljammer/.terraform/plugins/darwin_amd64/terraform-provider-local_v1.1.0_x4 pid=12534
2019-08-23T16:07:53.562-0700 [DEBUG] plugin: waiting for RPC address: path=/Users/miketitus/Workspace/git/spelljammer/clusters/dev-spelljammer/.terraform/plugins/darwin_amd64/terraform-provider-local_v1.1.0_x4
2019-08-23T16:07:53.568-0700 [DEBUG] plugin.terraform-provider-local_v1.1.0_x4: 2019/08/23 16:07:53 [DEBUG] plugin: plugin address: unix /var/folders/_w/xlscwzf103d74jjhh8t4n4280000gp/T/plugin267089085

2019-08-23T16:07:53.568-0700 [WARN]  plugin: plugin failed to exit gracefully
Error: Failed to instantiate provider "local" to obtain schema: Incompatible API version with plugin. Plugin version: 4, Client versions: [5]


2019-08-23T16:07:53.570-0700 [DEBUG] plugin: plugin process exited: path=/Users/miketitus/Workspace/git/spelljammer/clusters/dev-spelljammer/.terraform/plugins/darwin_amd64/terraform-provider-local_v1.1.0_x4 pid=12534 error="signal: killed"

Hi @miketitus,

It sounds like you have an older copy of the local provider already installed in your .terraform directory, and so Terraform is trying to use it in preference to downloading a newer version.

There are a couple different ways you can proceed here:

  • If you just want a one-off local solution, you could try just deleting the .terraform directory and running terraform init to get Terraform to re-install all of the dependencies. That should either get you into a working state or give you a message explaining why that’s not possible (e.g. if the local provider is constrained to only versions that are not Terraform 0.12-compatible.)
  • Alternatively, you could add an explicit version constraint to the configuration to indicate that only the versions that are v0.12-compatible are acceptable, and then run terraform init and Terraform should see that your existing installed version is not compatible and upgrade it.

To add the version constraint, either find an existing Terraform block or create a new one and put the required_providers block inside it:

terraform {
  required_providers {
    local = "~> 1.2.0"
  }
}

An advantage of an explicit version constraint is that it should also fix things for anyone else who is in the same situation as you, of having an existing .terraform directory containing plugin versions that are no longer appropriate. If you’d like to do it for the AWS provider too then a suitable version constraint could be "~> 2.7.0", where 2.7.0 is the release that introduced Terraform 0.12 compatibility.

terraform {
  required_providers {
    local = "~> 1.2.0"
  }
}

Adding this block and running terraform init resolved my problem, thank you!

What file do you add this bloc to?
terraform {
required_providers {
local = “~> 1.2.0”
}
}

if i created unversioned local provider, will that make a difference?

thats what i have now

  • provider.infoblox (unversioned)
  • provider.vsphere v1.13.0

and thats the error message im getting:

Failed to instantiate provider “infoblox” to obtain schema: exec: “C:\terraform\terraform-provider-infoblox”: file does not exist

Any help would be highly appreciated