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:
@user3869623's solution works for me. I'd like to share some details of mine to complete the picture.
My makefile contains below target:
clean:
@echo '$(OS)'
ifeq ($(OS),Windows_NT)
del /s *.o *.d *.elf *.map *.log
endif
When I run make clean
, I see this error:
Since it says something went wrong with echo
, so I change my makefile target to below:
clean:
ifeq ($(OS),Windows_NT)
del /s *.o *.d *.elf *.map *.log
endif
This time, make clean
gives me this error:
I am surprised to see bash
here since I am working in Windows command line.
Then I checked my %PATH%
, I see this entry:
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.
BUT I STILL DON'T KNOW WHY BASH GET INTO THIS???
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:
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
.
In my case I found a variable linking to cygwin bin folder C:\cygwin64\bin
, removed it and it worked.
I didn't want to remove GIT's bin folder from the PATH variable (I am using a Windows machine), as I use it quite often. So I looked for a workaround, and here it is:
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. :)
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.
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
.
This is almost certainly because the value of %PATH%
(or whatever) is different when make spawns a shell/console then when you have it open manually.
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.
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:
set path=%path:git\bin=;%
set path=%path:mingw64\bin=;%
set path=%path:usr\bin=;%
This hides the extra sh.exe instances from make for that instance only.
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.