I'm running make version 4.1 Built for x86_64-pc-linux-gnu on WSL Ubuntu. I have the following makefile and I'm trying to run make with it. However it fails when I run it with the error message:

make: /bin/bash : Command not found
makefile:18: recipe for target 'cc' failed
make: *** [cc] Error 127

I checked the /bin/ folder and bash does exists so I have no idea why this isn't working. Could anyone enlighten me?


GNU make is parsing the trailing whitespace after the SHELL := /bin/bash as part of the executable name. As noted in GNU make: How to Use Variables

You can also use them to introduce controlled leading whitespace into variable values. Leading whitespace characters are discarded from your input before substitution of variable references and function calls; this means you can include leading spaces in a variable value by protecting them with variable references, like this:

nullstring :=
space := $(nullstring) # end of the line

Here the value of the variable space is precisely one space. The comment `# end of the line' is included here just for clarity. Since trailing space characters are not stripped from variable values, just a space at the end of the line would have the same effect (but be rather hard to read). If you put whitespace at the end of a variable value, it is a good idea to put a comment like that at the end of the line to make your intent clear. Conversely, if you do not want any whitespace characters at the end of your variable value, you must remember not to put a random comment on the end of the line after some whitespace, such as this:

dir := /foo/bar    # directory to put the frobs in

Here the value of the variable dir is /foo/bar (with four trailing spaces), which was probably not the intention. (Imagine something like $(dir)/file with this definition!)

  • My god, Your a life saver. I thought there might be something wrong with my install. I knew about the whitespace feature but I thought it would auto truncate for executables like the shell. Didn't even occur to me that thats where the problem is. Thank you, this fixed it. – Mohsin Kale Dec 31 '18 at 17:01
  • @MohsinKale you're welcome - TBH at first I thought it must be something WSL specific - only started digging after I tested it on native Ubuntu and got the same behavior – steeldriver Dec 31 '18 at 17:03
  • I agree, in my defence it doesn't help that in the error message the space is truncated but in the actual make interpreter it isn't – Mohsin Kale Dec 31 '18 at 17:17
  • @MohsinKale if you look carefully you will notice it says make: /bin/bash : Command not found not make: /bin/bash: Command not found ;) – steeldriver Dec 31 '18 at 17:28
  • Damn, You're Right. It just looked so natural. – Mohsin Kale Dec 31 '18 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.