terraform-provider-libvirt: Terraform Error: Failed to instantiate provider "registry.terraform.io/dmacvicar/libvirt" to obtain schema: Unrecognized remote plugin message

I tried this in two different systems. First System is Centos 7.8, the other system is Ubuntu 18.04.5 LTS Bionic. My Terraform version is v0.13.4.

I used the following provider information in my main.tf:

terraform {
  required_providers {
    libvirt = {
      source  = "dmacvicar/libvirt"
      version = "0.6.2"
    }
  }
}

Also, I downloaded the “terraform-provider-libvirt” version 0.6.2 to “~/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.2/linux_amd64” directory. I saw this directory in some examples.

When I run the “terraform init” command, there was no error. After that, when I run the “terraform apply” command, I encountered the following error:

Error: Could not load plugin

Plugin reinitialization required. Please run “terraform init”.

Plugins are external binaries that Terraform uses to access and manipulate resources. The configuration provided requires plugins which can’t be located, don’t satisfy the version constraints, or are otherwise incompatible.

Terraform automatically discovers provider requirements from your configuration, including providers used in child modules. To see the requirements and constraints, run “terraform providers”.

Failed to instantiate provider “registry.terraform.io/dmacvicar/libvirt” to obtain schema: Unrecognized remote plugin message:

This usually means that the plugin is either invalid or simply needs to be recompiled to support the latest protocol.

How can I get rid of this problem, what is the solution?

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 22 (8 by maintainers)

Most upvoted comments

Hi everybody. Thanks a lot for the feedback. 🙏

I am not going to invest much time debugging these problems. Most of the work is happening on the pure-go branch, where we get rid of libvirt client side. 🧑‍🏭

This means:

  • It will work with Terraform on MacOS and Windows
  • We will have a single provider for each OS (Linux, MacOS, Windows), and not per Linux distro/libvirt version.
  • We will be able to publish it in the Terraform registry for easy and automatic setup

If anyone wants to improve the situation, I welcome helping us testing the pure-go branch so that we can realease as soon as possible.

Confirmed, this works:

terraform {
  required_providers {
    libvirt = {
      source  = "local/macvicar/libvirt"
      version = ">= 0.6.3"
    }
  }
}

provider "libvirt" {
  uri = "qemu:///system"
}

resource "libvirt_domain" "terraform_test" {
  name = "terraform_test"
}

If you put your plugin at: .terraform.d/plugins/local/macvicar/libvirt/0.6.3/linux_amd64.

Building from source and moving the executable to the directory and using the name @bnevis-i suggested using terraform v0.13.6 worked for me.

I have the same problem.

[root@server terraform]# pwd
/root/terraform
[root@server terraform]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@server terraform]# virsh version --daemon
Compiled against library: libvirt 4.5.0
Using library: libvirt 4.5.0
Gebruikte API: QEMU 4.5.0
Draaiende hypervisor: QEMU 1.5.3
Running against daemon: 4.5.0

[root@server terraform]# terraform -v
Terraform v0.14.7
+ provider registry.terraform.io/dmacvicar/libvirt v0.6.3
[root@server terraform]# ls -lash
totaal 12K
   0 drwxr-xr-x.  2 root root   51  3 mrt 22:01 .
4,0K dr-xr-x---. 18 root root 4,0K  3 mrt 21:52 ..
4,0K -rw-r--r--.  1 root root  204  3 mrt 21:58 libvirt.tf
4,0K -rw-r--r--.  1 root root  283  3 mrt 21:58 .terraform.lock.hcl
[root@server terraform]# cat libvirt.tf
terraform {
 required_version = ">= 0.14"
  required_providers {
    libvirt = {
      source  = "dmacvicar/libvirt"
      version = "0.6.3"
    }
  }
}

provider "libvirt" {
  uri = "qemu:///system"
}
[root@server terraform]# terraform init

Initializing the backend...

Initializing provider plugins...
- Reusing previous version of dmacvicar/libvirt from the dependency lock file
- Installing dmacvicar/libvirt v0.6.3...
- Installed dmacvicar/libvirt v0.6.3 (unauthenticated)

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
[root@server terraform]# terraform plan

Error: Could not load plugin


Plugin reinitialization required. Please run "terraform init".

Plugins are external binaries that Terraform uses to access and manipulate
resources. The configuration provided requires plugins which can't be located,
don't satisfy the version constraints, or are otherwise incompatible.

Terraform automatically discovers provider requirements from your
configuration, including providers used in child modules. To see the
requirements and constraints, run "terraform providers".

Failed to instantiate provider "registry.terraform.io/dmacvicar/libvirt" to
obtain schema: Unrecognized remote plugin message:

This usually means that the plugin is either invalid or simply
needs to be recompiled to support the latest protocol.


[root@server terraform]#
[root@server terraform]# find ~/.terraform.d/
/root/.terraform.d/
/root/.terraform.d/checkpoint_signature
/root/.terraform.d/plugins
/root/.terraform.d/plugins/terraform-provider-libvirt
/root/.terraform.d/plugins/registry.terraform.io
/root/.terraform.d/plugins/registry.terraform.io/terraform-provider-libvirt
/root/.terraform.d/checkpoint_cache
[root@server terraform]# find ~/.local/
/root/.local/
/root/.local/share
/root/.local/share/terraform
/root/.local/share/terraform/plugins
/root/.local/share/terraform/plugins/registry.terraform.io
/root/.local/share/terraform/plugins/registry.terraform.io/dmacvicar
/root/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt
/root/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.3
/root/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.3/linux_amd64
/root/.local/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.3/linux_amd64/terraform-provider-libvirt
[root@server terraform]#

I’ve had better results with ~/.terraform.d/plugins/registry.terraform.io/dmacvicar/libvirt/0.6.3/linux_amd64/terraform-provider-libvirt_v0.6.3 instead. (I am using 0.6.3.)