./configure : /bin/sh^M : bad interpreter [duplicate]

Solution 1:

To fix, open your script with vi or vim and enter in vi command mode (key Esc), then type this:

:set fileformat=unix

Finally save it

:x! or :wq!

Solution 2:

Looks like you have a dos line ending file. The clue is the ^M.

You need to re-save the file using Unix line endings.

You might have a dos2unix command line utility that will also do this for you.

Solution 3:

Or if you want to do this with a script:

sed -i 's/\r//' filename