git CreateProcess error = 2,系统找不到指定的文件错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48043878/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CreateProcess error = 2, the system cannot find the file specified error
提问by Raghav
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
我在 Windows 上有 Android Studio 2.3.3,在 Windows 上也有 Git。我从 GitHub ( VCS->Checkout from version control->Git->pasted the link ) 克隆了一个存储库并尝试运行它。但是 gradle 同步失败并给出了这个错误
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
给出的路径是我在结账时选择的位置。
我尝试在 Android Studio 中将 git.exe 的路径从 ...\bin\git.exe 更改为 ...\cmd\git.exe。
我还将 git.exe 的路径添加到我的环境 PATH 变量中,但错误仍然存在。
SO 上的其他答案主要是告诉执行这些步骤,但由于我已经完成了这些步骤,因此我不得不提出一个新问题。
另外,我的朋友建议我安装 Github Desktop,但我不能,因为我有 32 位操作系统。
注意 - 我对版本控制完全陌生。
编辑 - 日志的一部分
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
采纳答案by VonC
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
:
确保您如何添加git.exe
到您的 PATH:虽然在 Android studio 中您需要指定包含 的完整路径git.exe
,但您只需要git.exe
在您的 中添加父文件夹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
.
C:\path\to\Git 可以是您解压缩 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.
这需要在您的 USER Environment variables 中完成,如果您希望从中启动任何进程(如 Gradle)以继承您的新%PATH%
值,您需要关闭并重新打开 Android Studio 。