terraform init 失败 - git 必须可用并且在 PATH 上 [英] terraform init fails - git must be available and on the PATH

查看:127
本文介绍了terraform init 失败 - git 必须可用并且在 PATH 上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行 terraform init/get 时遇到问题.

I'm facing a problem when running terraform init / get.

我得到的错误:

Error downloading modules: Error loading modules: error downloading 'ssh://git@github.com/etc etc': git must be available and on the PATH

github 路径正确,在另一台机器上可以正常工作.

The github path is correct, works fine on another machine.

Git 工作正常,它也在 PATH 中.TF_LOG 为空.在 ubuntu 上工作.

Git works fine, it's in the PATH as well. TF_LOGs are empty. Working on ubuntu.

谢谢!

推荐答案

我不知道你是否解决了你的问题,但我遇到了同样的问题,然后解决了.分享答案以防其他人需要帮助.

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

  • Ubuntu 18.04
  • Linux Ubuntu 4.15.0-45-generic
  • 通过 Snap 安装 Terraform v0.11.11 Rev 216

错误来自文件 terraform/vendor/github.com/hashicorp/go-getter/get_git.go Get 函数.该函数首先尝试的是以下调用

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")
}

这会导致 go 在 path 中列出的所有文件夹中搜索具有提供名称的文件,在本例中为 git.我创建并执行了一个执行相同调用的 go 脚本,它的行为符合预期,发现 git 没有错误.

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.

之后,我从 snap 中卸载了 terraform,并直接从 Hashicorp 网站下载了可执行文件.当我运行仍然是 v0.11.11 的可执行文件版本时,它运行没有问题.这使我相信该错误与 snap 运行可执行文件的方式或 snap 安装应用程序周围的权限模型有关.

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:卸载 Terraform 的 snap 安装版本,然后下载并使用 Hashicorp 二进制文件.

TL;DR: Uninstall the snap installed version of Terraform and instead download and use the Hashicorp binary.

这篇关于terraform init 失败 - git 必须可用并且在 PATH 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆