Skip to content
Latchkey

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".

Gradle
/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

  1. Mark gradlew executable in git so every checkout is runnable.
  2. Commit the mode change.
  3. Re-run CI; the file is now executable on the runner.
Terminal
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.

.github/workflows/ci.yml
- run: bash ./gradlew build

How to prevent it

  • Keep gradlew tracked as executable (mode 100755) in git.
  • Avoid re-adding the wrapper from a filesystem that loses Unix modes.
  • Verify git ls-files --stage gradlew shows 100755.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →