Fix for permission denied error for gradlew command
It is a short tutorial on how to fix a gradlew permission denied error.
When you run the gradlew command with any task, You got the following error in windows as well as Linux.
$ ./gradlew compile
-bash: ./gradlew: Permission denied
gradlew: Permission denied
is a permission error on a Linux or Unix machine, So you have to change permissions for the gradlew wrapper command.
First, check available permissions for the file using the below command.
ls -l gradlew
We can do it in different ways using the below approach.
First approach,
Change the permissions to be executable with the chmod
command.
chmod +x gradlew
This works with the local installation gradlew command.
Suppose the same project is used by multiple developers from the repository and everyone has to do the same command to change permissions.
Instead, You can update permissions to the git repository Second approach,
Here are the steps to do in the git repository to commit changes
To change the permissions, change the git work tree to update permissions with the below command.
git update-index --chmod=+x gradlew
Add these changes using the below command.
git add .
Next, commit changes to the local repository using the below command.
git commit -m "Update execute permission for gradlew command".
finally, push the changes using the push command to the remote repository
git push
Conclusion
permissions issues in gradlew are happening due to no executable permissions for the gradlew command.
update execute permission using local or global repository.