Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gradlew is not found (No such file or directory)

Tags:

gradle

gradlew

I load a project from git and build it successfully on MacBook. When I type './gradlew assembleRelease' in terminal window, I get an error:

bash: ./gradlew: No such file or directory

So I check if gradlew is under the project dir, but I can not find it. But I can still run task from 'Gradle projects' window.

What's wrong?

like image 225
huyn Avatar asked Dec 31 '16 11:12

huyn


People also ask

How do I run gradlew on Windows 10?

To run a Gradle command, open a command window on the project folder and enter the Gradle command. Gradle commands look like this: On Windows: gradlew <task1> <task2> … ​ e.g. gradlew clean allTests.

Where is the gradlew file?

gradle file is located inside your project folder under app/build. gradle.


4 Answers

gradlew script is so-called Gradle wrapper, a self-contained script which allows people to run Gradle tasks without gradle installed. However it doesn't have to exist to execute Gradle tasks, it's absolutely optional.

You can generate Wrapper in your project by executing the task

gradle wrapper

Afterward, you can use ./gradlew script instead of gradle from PATH

To specify a Gradle version use --gradle-version on the command-line. Just execute the command:

gradle wrapper --gradle-version <your gradle version>

Take a look here for more exhaustive and comprehensive explanation: https://docs.gradle.org/current/userguide/gradle_wrapper.html

like image 86
Sergei Voitovich Avatar answered Oct 18 '22 02:10

Sergei Voitovich


In my case I copied gradlew file from windows(10) to linux(centos7).

So had to run

[user@server]$ dos2unix gradlew

And it worked.

Update:

If you have copied from windows as in my case. Do one thing, open it in notepad++, Go to View -> Show Symbol -> Show End of Line. You can notice CRLF This is the Windows EOL. Now convert it so you don't have to redo it. To convert notepad++ -> Edit -> EOL Conversion -> Unix (LF)

That's it, while pushing to git fiddle aroung .gitattributes

like image 41
Ranvir Avatar answered Oct 18 '22 01:10

Ranvir


No such file or directory (bash: ./gradlew)

Add the execute permission for all users to the existing permissions

chmod +x gradlew
like image 6
yoAlex5 Avatar answered Oct 18 '22 01:10

yoAlex5


In my case I have moved the project from a Windows machine to Mac and it contains carriage returns '\r'.

brew install dos2unix

find . -type f -exec dos2unix {} \;

./gradlew clean build

like image 2
Shah Avatar answered Oct 18 '22 01:10

Shah