[英]Intellij import issue - java.io.IOException: Cannot run program “git”: error=2, No such file or directory
I am attempting to import a project from github into intellij and am running into this stack trace: 我正在尝试将项目从github导入intellij并且正在运行此堆栈跟踪:
Caused by: 引起:
java.io.IOException: Cannot run program "git": error=2, No such file or directory at common_c6b3s0xd8gl4x9r47zsnga1nq$_run_closure12.doCall(/Users/jrengh/Documents/teri/common.gradle:97)
java.io.IOException:无法运行程序“git”:error = 2,没有这样的文件或目录在common_c6b3s0xd8gl4x9r47zsnga1nq $ _run_closure12.doCall(/Users/jrengh/Documents/teri/common.gradle:97)
I have seen this issue posted around the internet a lot and the common solution seems to be to make sure that the git executable is correctly listed in the "Path to git executable" field under Settings > Version control > Git. 我已经看到这个问题在互联网上发布很多,常见的解决方案似乎是确保git可执行文件正确地列在设置>版本控制> Git下的“路径到git可执行文件”字段中。 I have done so, tested the connection and have gotten a successful message.
我已经这样做了,测试了连接并获得了成功的消息。
The issue stems from this task method called in a separate gradle file located within one of my project's dependencies: 问题源于此任务方法,该方法在位于我的项目依赖项之一的单独gradle文件中调用:
task buildInfo {
def cmd = "git rev-parse --short HEAD"
def proc = cmd.execute()
project.ext.revision = proc.text.trim()
cmd = "git show -s --format=%ct HEAD"
proc = cmd.execute()
project.ext.timestamp = proc.text.trim()
}
So essentially, intellij doesn't recognize the "git" in the command I try to execute above even though I have successfully uploaded a git executable. 基本上,即使我已经成功上传了一个git可执行文件,intellij也不会识别我尝试在上面执行的命令中的“git”。 Does anyone have any helpful suggestions?
有没有人有任何有用的建议?
I have just installed a fresh Ubuntu Gnome 15.10 and Git was not installed. 我刚刚安装了一个新的Ubuntu Gnome 15.10并没有安装Git。
On Ubuntu to install Git: 在Ubuntu上安装Git:
sudo apt-get install git
Intellij Idea can of course not execute a command it does not find. Intellij Idea当然不能执行它找不到的命令。
So as it turned out, if I used the full directory location ('/usr/local/git/bin/git' in my case) instead of simply 'git' in those command executions, then the problem was solved. 事实证明,如果我使用完整的目录位置(在我的情况下是'/ usr / local / git / bin / git')而不是在那些命令执行中只是'git',那么问题就解决了。 So for example, the first line of the method had to read "def proc = /usr/local/git/bin/git rev-parse --short HEAD".
因此,例如,该方法的第一行必须读取“def proc = / usr / local / git / bin / git rev-parse --short HEAD”。
If I were attempting to edit this code in a team setting (such as pushing it back into github for the other members of my team to see), then I would need to alias this directory location so that "git" could remain in the code and still work on my machine; 如果我试图在团队设置中编辑此代码(例如将其推回到github以供我团队的其他成员查看),那么我需要为此目录位置设置别名,以便“git”可以保留在代码中并仍在我的机器上工作; however since I do not plan on pushing this back into github, this is all I need.
但是因为我不打算将其推回到github,所以这就是我所需要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.