Gradle "./gradlew: Permission denied" in CI
The shell found gradlew but it has no executable permission, so it refuses to run it and exits 126. The file is usually committed without its +x bit, often from a Windows checkout or a copy that dropped the mode.
What this error means
A step running ./gradlew ... fails with "/usr/bin/env: ‘bash’" issues or, more commonly, "./gradlew: Permission denied" and "Process completed with exit code 126".
/home/runner/work/_temp/script.sh: line 1: ./gradlew: Permission denied
Error: Process completed with exit code 126.Common causes
The executable bit is missing in git
The committed gradlew has mode 100644, not 100755, so the checkout writes a non-executable file.
A Windows or archive copy dropped the mode
Adding the wrapper from a filesystem that does not track Unix permissions stored it without +x.
How to fix it
Set the executable bit in the repository
- Mark
gradlewexecutable in git so every checkout is runnable. - Commit the mode change.
- Re-run CI; the file is now executable on the runner.
git update-index --chmod=+x gradlew
git commit -m "Make gradlew executable"Run it through bash as a stopgap
Invoking the script via an interpreter sidesteps the missing bit, though fixing the mode in git is the durable fix.
- run: bash ./gradlew buildHow to prevent it
- Keep
gradlewtracked as executable (mode 100755) in git. - Avoid re-adding the wrapper from a filesystem that loses Unix modes.
- Verify
git ls-files --stage gradlewshows 100755.