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

房东的猫 提交于 2019-11-28 20:06:59

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.

Justin Rhoades

This is because the gradlew file has Windows file-endings.

You can install dos2unix with apt-get or yum by running:

sudo apt-get install dos2unix

sudo yum install -y dos2unix

and then use dos2unix to convert the line-endings

from CRLF Windows CarriageReturn + LineFeed

to LF Linux LineFeed only:

dos2unix ./gradlew

Then run your gradlew for a test:

./gradlew clean -d

Thanks for the answers, these highlighted that the problem was Windows creating the gradlew, when I am on mac.

To fix this, from the directory of the app I ran the command:

gradle wrapper

This creates (replaces the broken) a gradle wrapper, that works! (notice it uses your local gradle install to fix the wrapper of the app)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!