Error with gradlew: /usr/bin/env: bash: No such file or directory

Matthias Braun picture Matthias Braun · Mar 10, 2014 · Viewed 41.3k times · Source

After committing my project's gradlew file from my Windows machine to the remote repo using Git, invoking gradlew on my Linux server failed with this message:

/usr/bin/env: bash: No such file or directory

What happened?

Answer

Matthias Braun picture Matthias Braun · Mar 10, 2014

The problem's cause was that Git on Windows converted the line endings of gradlew from Unix style (LF) to Windows style (CRLF).

You can turn off that automatic conversion using git config core.autocrlf false.

Setting the line endings of gradlew back to Unix style fixed the problem. In Vim this is done using :set fileformat=unix.