Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

./gradlew will not run: permission denied

Errorbash: ./gradlew: Permission denied

Short answer

The gradlew script has lost its executable bit, usually after a zip download, a Windows checkout or a copy to another disk. Run chmod +x gradlew locally. To fix it for everyone, record the bit in Git with git update-index --chmod=+x gradlew and commit.

  • Applies to Gradle 8.x, Gradle 9, Git 2.x, Ubuntu 24.04, macOS
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check the permission string. If there is no x in it, this page applies.

    ls -l gradlew
  2. 2Match what you see, then jump to its fix

    1. 1-rw-r--r-- on gradlewThe file has no executable bit on your machineFix
    2. 2Works on your Mac, fails in CI or on a fresh clone with the same messageGit stored the file as non-executable, so CI checks it out that wayFix
    3. 3gradlew is missing, or the next error is about gradle-wrapper.jarThe wrapper files were never committed togetherFix

What does the error look like?

  • bash: ./gradlew: Permission denied
  • zsh: permission denied: ./gradlew

Cause 1 of 3

The file has no executable bit on your machine

1Check

A zip download, an unzip from Windows or a copy to an exFAT or NTFS disk does not keep Unix permissions.

ls -l gradlew

2Fix

Add the executable bit to the launcher script.

chmod +x gradlew

3Verify

The Gradle version prints.

./gradlew --version

Confirmed by docs.gradle.org

Did this fix it?

Cause 2 of 3

Git stored the file as non-executable, so CI checks it out that way

1Check

The index mode for the file should be 100755. If it shows 100644, every clone gets a script that cannot run.

git ls-files --stage gradlew

2Fix

Set the bit in the index and commit. Git's own documentation describes --chmod=(+|-)x for this.

git update-index --chmod=+x gradlew
git commit -m "Make gradlew executable"

3Verify

The index now shows mode 100755.

git ls-files --stage gradlew

Confirmed by git-scm.com

Did this fix it?

Cause 3 of 3

The wrapper files were never committed together

1Check

Gradle's documentation lists four files that belong in version control: gradlew, gradlew.bat, gradle-wrapper.jar and gradle-wrapper.properties.

git ls-files gradlew gradlew.bat gradle/wrapper

2Fix

Regenerate the wrapper with an installed Gradle, then commit all four files.

gradle :wrapper
git add gradlew gradlew.bat gradle/wrapper

3Verify

A fresh clone builds.

./gradlew --version

Confirmed by docs.gradle.org

Did this fix it?

How do I stop it coming back?

  • Commit the executable bit once with git update-index --chmod=+x and never copy the project through a zip.
  • In CI, call ./gradlew only after checkout, and keep a check that fails on mode 100644.
  • Work on Linux-style filesystems for Gradle projects, not exFAT or NTFS.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.