10

I am attempting to import a project from github into intellij and am running into this stack trace:

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)

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. 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:

common.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. Does anyone have any helpful suggestions?

8
  • Chuck git into the user/system PATH? Commented Sep 22, 2015 at 20:14
  • I assume you mean add the git as a path variable? Commented Sep 22, 2015 at 20:21
  • Yes, outside of the IDE. Commented Sep 22, 2015 at 20:23
  • I attempted to do so by accessing Settings > Build, Execution, Deployment and adding the git path, but that did not have any effect. Commented Sep 22, 2015 at 20:27
  • I mean, set the PATH environment variable outside of the the IDE. This would then be inherited to all sub-processes, even if they ignore other path settings. It's a punt approach. Commented Sep 22, 2015 at 20:29

2 Answers 2

11

I have just installed a fresh Ubuntu Gnome 15.10 and Git was not installed.

On Ubuntu to install Git:

sudo apt-get install git

Intellij Idea can of course not execute a command it does not find.

Sign up to request clarification or add additional context in comments.

Comments

1

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. So for example, the first line of the method had to read "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; however since I do not plan on pushing this back into github, this is all I need.

1 Comment

For my case changing Version Control > Git > Path to Git executable to the absolute path (you can get that through running which git) instead of just git did the trick

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.