4

I have Backend codes and APIs in a folder I download it from mail. I am using Mac OS.

But when I run ./mvnw in terminal I got the error

-bash: ./mvnw: /bin/sh^M: bad interpreter: No such file or directory

How to overcome this error?

Patrick
  • 12,336
  • 15
  • 73
  • 115
Sakthi
  • 85
  • 1
  • 1
  • 11
  • 1
    Shouldn't be /bin/bash?. Seems you don't have such shell. Also you are using Windows generated/modified file (^M is "newline" on windows) on linux. Try to get rid of it from script (if you are possitive that you have such shell) – Antoniossss Oct 09 '18 at 06:35
  • are you running this command from the directory where pom.xml lies? – Shubham Dixit Oct 09 '18 at 06:35
  • yes I am running from that directory @JaiDixit – Sakthi Oct 09 '18 at 06:42
  • 1
    `^M`= Ctrl-M = ASCII 13 (M being the 13th letter) = CR, `\r`. Where CR+LF, `\r\n` is the Windows line ending as opposed to `\n` for MacOSX, Linux and more. You might edit mvnw and remove then `\r`s. – Joop Eggen Oct 09 '18 at 07:27
  • I got it, changed to MacOSx @JoopEggen,@Antoniossss – Sakthi Oct 09 '18 at 08:53

5 Answers5

10

I had the same error as you, installing mvn wrapper in the following way worked for me.

mvn -N io.takari:maven:wrapper

Then cd to the folder where pom.xml file is, and then re-run the ./mvnw command

shubh_ansh
  • 103
  • 1
  • 3
3

It looks like your bash gets confused by DOS line endings. This post goes into some detail on how to handle those on MacOS

OhleC
  • 2,821
  • 16
  • 29
1

I tried dos2unix filename it works. For using this command we have to install dos2unix

This is the link for install

https://symwisedownload.symantec.com//resources/sites/SYMWISE/content/live/SOLUTIONS/228000/TECH228385/en_US/dos2unix-5.3.3-0.pkg?gda=1539204692_786de4ebe956ae8f24de673f5398dd64

Sakthi
  • 85
  • 1
  • 1
  • 11
0

The error suggests that the mvnw file is not there. Go to your maven project which you need to build and then run mvnw like bellow by pointing to the path of mvnw.

sh /home/user/maven-wrapper-master/mvnw clean install

Or else copy the mvnw file into the maven project directory.

Rans
  • 422
  • 2
  • 8
0

I had the same error, so in this situation ./mvnw doesn`t work, but I tried to write the absolute path to the mvnw file and it works! So try it!