windows Makefile error make (e=2): 系统找不到指定的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33674973/
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
Makefile error make (e=2): The system cannot find the file specified
提问by Colonel Beauvel
I am using a makefile in windows to push some files on a Unix server (here a text file "blob.txt" in the same folder of my makefile). My makefile script is:
我在 Windows 中使用 makefile 在 Unix 服务器上推送一些文件(这里是我的 makefile 的同一文件夹中的文本文件“blob.txt”)。我的makefile脚本是:
setup:
pscp blob.txt username@hostname:/folder/
I start a command prompt, go in the folder where blob.txt and the makefile are present and type:
我启动命令提示符,进入 blob.txt 和 makefile 所在的文件夹并键入:
make setup
Which results in:
结果是:
pscp blob.txt username@hostname:/folder/
process_begin: CreateProcess(NULL, pscp blob.txt username@hostname:/folder/, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [setup] Error 2
In a #fail ... whereas if I enter directly the command in the command prompt:
在 #fail ... 而如果我直接在命令提示符中输入命令:
pscp blob.txt username@hostname:/folder/
It works ... I really wonder why.
它有效......我真的很想知道为什么。
回答by Etan Reisner
The error
错误
process_begin: CreateProcess(NULL, pscp blob.txt username@hostname:/folder/, ...) failed.
make (e=2): The system cannot find the file specified.
is almost certainly complaining that Windows cannot find pscp
.
几乎肯定是在抱怨 Windows 找不到pscp
.
This is almost certainly because the value of %PATH%
(or whatever) is differentwhen make spawns a shell/console then when you have it open manually.
这是几乎可以肯定,因为价值%PATH%
(或其他)是不同时许产生一个壳/控制台那么当你拥有了它手动打开。
Compare the values to confirm that. Then either use the full path to pscp
in the makefile recipe or ensure that the value of PATH
is set correctly for make
's usage.
比较这些值以确认这一点。然后pscp
在 makefile 配方中使用完整路径或确保PATH
为make
的使用正确设置了 的值。
回答by user3869623
In my case i had git\bin in my %PATH%
which contains bash.exe and sh.exe.. Removing %GIT_HOME%\bin
from the PATH
worked for me
就我而言,我的 git\bin 中%PATH%
包含 bash.exe 和 sh.exe ..%GIT_HOME%\bin
从PATH
对我来说有效的工作中删除
回答by smwikipedia
@user3869623's solution works for me. I'd like to share some details of mine to complete the picture.
@ user3869623 的解决方案对我有用。我想分享一些我的细节来完成这张照片。
My makefile contains below target:
我的 makefile 包含以下目标:
clean:
@echo '$(OS)'
ifeq ($(OS),Windows_NT)
del /s *.o *.d *.elf *.map *.log
endif
When I run make clean
, I see this error:
当我运行时make clean
,我看到这个错误:
Since it says something went wrong with echo
, so I change my makefile target to below:
由于它说出现了问题echo
,所以我将我的 makefile 目标更改为以下内容:
clean:
ifeq ($(OS),Windows_NT)
del /s *.o *.d *.elf *.map *.log
endif
This time, make clean
gives me this error:
这一次,make clean
给了我这个错误:
I am surprised to see bash
here since I am working in Windows command line.
我很惊讶地看到bash
这里,因为我在 Windows 命令行中工作。
Then I checked my %PATH%
, I see this entry:
然后我检查了我的%PATH%
,我看到了这个条目:
C:\DevTools\Git\bin
C:\DevTools\Git\bin
There's a bash.exe
and sh.exe
in that path. So I removed this entry, and it works fine now.
在那条路上有一个bash.exe
和sh.exe
。所以我删除了这个条目,现在它工作正常。
BUT I STILL DON'T KNOW WHY BASH GET INTO THIS???
但我仍然不知道为什么 BASH 会进入这个???
ADD 1
添加 1
As to why the C:\DevTools\Git\bin
shows up in my %PATH%
, because I am using Sublime and it always asks me for the Git binaries:
至于为什么C:\DevTools\Git\bin
出现在我的 中%PATH%
,因为我使用的是 Sublime 并且它总是要求我提供 Git 二进制文件:
回答by tkennon
I know this is an old question that has been answered, but thought I'd and my experiences for anyone still running into this. I was getting the same cryptic error Colonel Beauvel (though with the windows MOVE command, not pscp):
我知道这是一个已经得到回答的老问题,但我想我会和我的经历让任何人仍然遇到这个问题。我得到了同样的神秘错误上校 Beauvel(尽管使用 windows MOVE 命令,而不是 pscp):
process_begin: CreateProcess(NULL, move /y foo\bar.c .\baz.c, ...) failed.
make (e=2): The system cannot find the file specified.
Our CI was running the same Makefile and working perfectly. Turns out CI was using mingw32-make and I was using GNU make. Uninstalling GNU make (which got installed as part of an unrelated bulk package) and aliasing mingw32-make to 'make' works perfectly.
我们的 CI 运行相同的 Makefile 并且运行良好。结果证明 CI 使用的是 mingw32-make,而我使用的是 GNU make。卸载 GNU make(作为不相关的批量包的一部分安装)并将 mingw32-make 别名为 'make' 工作完美。
回答by Julie
To build on user3869623's response.
以 user3869623 的响应为基础。
In my case i had git\bin in my %PATH% which contains bash.exe and sh.exe.. Removing %GIT_HOME%\bin from the PATH worked for me
就我而言,我的 %PATH% 中有 git\bin,其中包含 bash.exe 和 sh.exe .. 从 PATH 中删除 %GIT_HOME%\bin 对我有用
While this recommendation may allow make
to run, it will likely cause issues for git, especially if the makefile is installing software from a git repository.
虽然此建议可能允许make
运行,但它可能会导致 git 出现问题,尤其是当 makefile 从 git 存储库安装软件时。
A better solution is to simply change %GIT_HOME%\bin
to %GIT_HOME%\cmd
更好的解决方案是简单地更改%GIT_HOME%\bin
为%GIT_HOME%\cmd
回答by Ricardo Alejos
I did't want to remove GIT's bin folder form the PATH variable (I am using a Windows machine), as I use it quite often. So I looked for a work around. And here it is:
我不想从 PATH 变量中删除 GIT 的 bin 文件夹(我使用的是 Windows 机器),因为我经常使用它。所以我寻找了一个解决方法。这是:
Add the <git-installation-directory>/usr/bin
directory to your PATH variable too. This basically adds the rest of the linux-like commands that come with the "GIT bash" to your environment. After applying this, my makefiles ran normally again. :)
将该<git-installation-directory>/usr/bin
目录也添加到您的 PATH 变量中。这基本上将“GIT bash”附带的其余类似 linux 的命令添加到您的环境中。应用此功能后,我的 makefile 再次正常运行。:)
If you are curious about what shell is being invoked by make, just add $(info $(SHELL))
at the beginning of your makefile. The path/name of the shell being invoked is printed to the console as soon as you run make.
如果您对 make 调用的 shell 感到好奇,只需$(info $(SHELL))
在 makefile 的开头添加即可。运行 make 后,正在调用的 shell 的路径/名称会立即打印到控制台。
回答by Moustafa El-Sayed
For those who tried removing the git bin folder from PATH
and it didn't work for them, search your PATH
variables for any paths containing bash.exe
.
对于那些尝试从中删除 git bin 文件夹PATH
但对他们不起作用的人,请在PATH
变量中搜索包含.git 文件的任何路径bash.exe
。
In my case I found a variable linking to cygwin bin folder C:\cygwin64\bin
, removed it and it worked.
就我而言,我发现了一个链接到 cygwin bin 文件夹的变量C:\cygwin64\bin
,将其删除并且它起作用了。
回答by MAF
I had the same issue, and this thread really helped me solve it. In my case, it was a conflict between make and the sh.exe that was visible through my path, due to both git and mingw64. To fix my issue, without breaking Git, I added these lines to the top of my batch file that calls make:
我有同样的问题,这个线程真的帮助我解决了它。就我而言,由于 git 和 mingw64,make 和通过我的路径可见的 sh.exe 之间存在冲突。为了在不破坏 Git 的情况下解决我的问题,我将这些行添加到调用 make 的批处理文件的顶部:
set path=%path:git\bin=;%
set path=%path:mingw64\bin=;%
set path=%path:usr\bin=;%
This hides the exstra sh.exe instances from make for that instance only.
这仅会为该实例隐藏额外的 sh.exe 实例。