问题
I have Android Studio 2.3.3 on Windows and also Git for Windows. I cloned a repository from GitHub ( VCS->Checkout from version control->Git->pasted the link ) and tried to run it. But the gradle sync failed giving this error
CreateProcess error=2, the system cannot find the file specified
I checked the log and I noticed this
java.io.IOException: Cannot run program "git" (in directory "H:\GitClone\apps-android-commons\app"): CreateProcess error=2, The system cannot find the file specified
The path given is the location I chose during checkout.
I tried changing the path for git.exe from ...\bin\git.exe to ...\cmd\git.exe in Android Studio.
I also added the path for git.exe to my environment PATH variables but the error has persisted.
Other answers on SO mostly tell to do these steps but as I had already done these I had to ask a new question.
Also, my friend advised me to install Github Desktop but I cannot because I have a 32 bit OS.
Note- I am completely new to version control.
Edit - A part of the log
Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'git''
at org.gradle.process.internal.DefaultExecHandle.execExceptionFor(DefaultExecHandle.java:220)
at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(DefaultExecHandle.java:204)
at org.gradle.process.internal.DefaultExecHandle.failed(DefaultExecHandle.java:340)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:86)
at org.gradle.internal.operations.BuildOperationIdentifierPreservingRunnable.run(BuildOperationIdentifierPreservingRunnable.java:39)
... 3 more
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'git'
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
at net.rubygrapefruit.platform.internal.WindowsProcessLauncher.start(WindowsProcessLauncher.java:22)
at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:68)
... 4 more
回答1:
Make sure how you add git.exe
to your PATH: while in Android studio yo need to specify the full path including git.exe
, you would need to add only the parent folder of git.exe
in your PATH
:
set PATH=C:\path\to\Git\bin;%PATH%
C:\path\to\Git can be any folder where you uncompressed the sef-extracted archive PortableGit-2.15.1-64-bit.7z.exe.
That needs to be done in your USER Environment variables, and you need to close and re-open Android Studio if you want any process (like Gradle) launch from it to inherit your new %PATH%
value.
来源:https://stackoverflow.com/questions/48043878/createprocess-error-2-the-system-cannot-find-the-file-specified-error