Fix for permission denied error for gradlew command


This is an short tutorial how to fix an gradlew permission denied error

Fix for permission denied error for gradle and wrapper command When you run gradlew command with any task, You got following error in windows as well as linux

$ ./gradlew compile
-bash: ./gradlew: Permission denied

gradlew: Permission denied is an permission error on linux or unix machine, So you have to change permissions for gradlew wrapper command.

First check avialiable permissions for the file using below command

$ ls -l gradlew

We can do in different ways using below approach

First approach,

Change the permissions to be executable with chmod command

$ chmod +x gradlew

This works with local installation gradlew command.

Suppose same project used by multiple developers from repository and everyone has to do the same command to change permissions.

Instead, You can update permissions to git repository Second approach,

Here are the steps to do in git repository to commit changes

To change the permissions, change the git work tree to update permissions with below command

git update-index --chmod=+x gradlew

Add these changes using below command

git add .

Next commit changes to local repository using below command

git commit -m "Update execute permission for gradlew command"

finally, push the changes using push command to remote repository

git push

Conclusion

permissions issues in gradlew are happening due to no executable permissions for gradlew command.

update execute permission using locally or globally repository.

THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
Subscribe
You'll get a notification every time a post gets published here.