go install github.com/dmacvicar/terraform-provider-libvirt@latest - shows error
Asked Answered
D

1

8

I am trying to Provision VMs on KVM with Terraform. one of the steps in installations is to download and install the provider buy the command:

go install github.com/dmacvicar/terraform-provider-libvirt@latest

but it errors:

The go.mod file for the module providing named packages contains one or more replace directives. It must not contain directives that would cause it to be interpreted differently than if it were the main module.

I didn't find a solution, is someone has faced it? thank you

Degeneration answered 2/11, 2021 at 8:13 Comment(0)
L
11

As JimB notice in comments:

If there are replace or exclude directives in the module, the correct installation method is to clone the source and install it,

git clone github.com/dmacvicar/terraform-provider-libvirt
cd terraform-provider-libvirt
go install
Letreece answered 2/11, 2021 at 8:21 Comment(7)
go get is deprecated as an installation command, and is only for managing dependencies. go install is the correct command once the correct source has been checked out locally to that replace directives can be used.Connie
Thanks, I've updated answer.Letreece
No, you shouldn't rely on trying to use go install then having it fail and changing into the GOPATH/pkg/mod source directory (if `go install worked, then there would be nothing else to do) - you checkout the desired source and build that source.Connie
I've checked it and go install wont compile anything.Letreece
it just clone sources in the GOPATH/pkg/modLetreece
That is true, but you're relying on go install erroring out here with the error above, and GOPATH/pkg/mod is not intended for direct usage (which is why it's all created read-only). If there are replace or exclude directives in the module, the correct installation method is to clone the source and install it, there's no reason to recommend otherwise.Connie
Ok, thanks, now it's clear for me, I've updated answer.Letreece

© 2022 - 2024 — McMap. All rights reserved.