I'm facing a problem when running terraform init / get.
Error I'm getting:
Error downloading modules: Error loading modules: error downloading 'ssh://[email protected]/etc etc': git must be available and on the PATH
The github path is correct, works fine on another machine.
Git works fine, it's in the PATH as well. TF_LOGs are empty. Working on ubuntu.
Thanks!
I don't know if you solved your issue or not but I ran into the same problem and then solved it. Sharing the answer in case someone else needs help.
For reference I encountered this issue on
The error comes from the file terraform/vendor/github.com/hashicorp/go-getter/get_git.go
the Get
function. The first thing that is attempted by the function is the following call
if _, err := exec.LookPath("git"); err != nil {
return fmt.Errorf("git must be available and on the PATH")
}
This causes go to search all of the folders listed in path for a file with the supplied name, in this case git
. I created and executed a go script that makes the same call and it behaved as expected, finding git without error.
After this I uninstalled terraform from snap and downloaded the executable straight from the Hashicorp website. When I ran that version of the executable which was still v0.11.11
it ran without issue. This leads me to believe that the error has something to do with how snap was running the executable or the permission model around snap installed apps.
TL;DR: Uninstall the snap installed version of Terraform and instead download and use the Hashicorp binary.
Uninstall the snap installed version of Terraform and instead download and use the Hashicorp binary.
As per the terraform documentation,
For github.com projects, to clone over SSH, use the
following form:
module "consul" {
source = "[email protected]:hashicorp/example.git"
}
For Arbitrary Git repositories use the special git:: prefix
module "storage" {
source = "git::ssh://[email protected]/storage.git"
}
Also, verify if Config ~/.ssh/config
is correct for your github account:
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With