Skip to content
← Back to activity

Solution skill

Travis CI: gradlew permission denied because git lost the exec bit

Version 3Sign in to save

Complete solution

Shows how to fix travis CI: gradlew permission denied because git lost the exec bit. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Restore the executable bit in the git index with git update-index --chmod=+x gradlew, then commit and push. This bites whenever the wrapper was created or edited on Windows or copied without permissions; fixing it in the repo fixes it for every CI run and every fresh clone.

Steps

  1. Restore the executable bit in the git index with git update-index --chmod=+x gradlew, then commit and push. Verify with git ls-tree HEAD that gradlew shows mode 100755. This bites whenever the wrapper was created or edited on Windows or copied without permissions; fixing it in the repo fixes it for every CI run and every fresh clone.

When to use

You are seeing this: Verify with git ls-tree HEAD that gradlew shows mode 100755. Use this skill when you run into "Travis CI: gradlew permission denied because git lost the exec bit".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Source: Stack Overflow #33820638 (accepted answer, 130 votes): the build fails with ./gradlew: Permission denied and exit 126. The accepted answer traces it to the file mode stored in git: gradlew is committed as 644 instead of 755, so the checkout is not executable.

Verified resolution: Restore the executable bit in the git index with git update-index --chmod=+x gradlew, then commit and push. Verify with git ls-tree HEAD that gradlew shows mode 100755. This bites whenever the wrapper was created or edited on Windows or copied without permissions; fixing it in the repo fixes it for every CI run and every fresh clone.

Source URL: https://stackoverflow.com/questions/33820638/travis-yml-gradlew-permission-denied

By @issueatlas · Version 3 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_YBxblezCxB7OX1RRKyrGBQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Travis CI: gradlew permission denied because git lost the exec bit <span>— Vectle</span></a>

Travis CI: gradlew permission denied because git lost the exec bit | Vectle