gradle / gradle-build-action

Execute your Gradle build and trigger dependency submission
https://github.com/marketplace/actions/gradle-build-action
MIT License
679 stars 97 forks source link

Error: Unable to locate executable file: gradle. #832

Closed yogurtearl closed 1 year ago

yogurtearl commented 1 year ago

Update: Workaround at the bottom

This is happening with Gradle 8.2.1-bin, but I think this stopped working with Gradle 8.1.0.

This is happening with v2.7.0 but have also observed something similar with v2.3.3

It may be related to newer versions of the gradle wrapper.

With config:

      - name: Enable actions/cache for Gradle
        uses: gradle/gradle-build-action@a4cf152f482c7ca97ef56ead29bf08bcd953284c # v2.7.0
        with:
          gradle-home-cache-cleanup: true
      - name: Gradle Build
        shell: bash
        run: |
          ./gradlew build

I am getting this error on the main branch:

2023-08-09T18:52:12.0656315Z In final post-action step, saving state and writing summary
2023-08-09T18:52:12.0795788Z Stopping all Gradle daemons before saving Gradle User Home state
2023-08-09T18:52:12.0830842Z Stopping Gradle daemons for /home/.gradle/wrapper/dists/gradle-8.2.1-bin/2gbabuewc4hf6etucmvjld9wn/gradle-8.2.1
2023-08-09T18:52:12.0831527Z [command]/home/.gradle/wrapper/dists/gradle-8.2.1-bin/2gbabuewc4hf6etucmvjld9wn/gradle-8.2.1/bin/gradle --stop
2023-08-09T18:52:13.2248326Z Stopping Daemon(s)
2023-08-09T18:52:13.2452843Z 1 Daemon stopped
2023-08-09T18:52:13.2453106Z Forcing cache cleanup.
2023-08-09T18:52:14.7348701Z ##[warning]Unhandled error in Gradle post-action - job will continue: Error: Unable to locate executable file: gradle. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
2023-08-09T18:52:14.7385886Z Error: Unable to locate executable file: gradle. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
2023-08-09T18:52:14.7387852Z     at Object.<anonymous> (/__w/_actions/gradle/gradle-build-action/a4cf152f482c7ca97ef56ead29bf08bcd953284c/dist/post/index.js:9789:27)
2023-08-09T18:52:14.7388725Z     at Generator.next (<anonymous>)
2023-08-09T18:52:14.7389780Z     at fulfilled (/__w/_actions/gradle/gradle-build-action/a4cf152f482c7ca97ef56ead29bf08bcd953284c/dist/post/index.js:9600:58)

Similar to https://github.com/gradle/gradle-build-action/issues/814 but different error message.

If I add this:

echo "$(find /home/.gradle/wrapper/dists/ -name gradle | xargs ls -tr | tail -n 1 | xargs dirname)" >> $GITHUB_PATH

then the error message changes to:

Unexpected error attempting to determine if executable file exists '/home/.gradle/wrapper/dists/gradle-8.2.1-bin/2gbabuewc4hf6etucmvjld9wn/gradle-8.2.1/bin/gradle/gradle': Error: ENOTDIR: not a directory, stat '/home/.gradle/wrapper/dists/gradle-8.2.1-bin/2gbabuewc4hf6etucmvjld9wn/gradle-8.2.1/bin/gradle/gradle'
Warning: Unhandled error in Gradle post-action - job will continue: Error: Unable to locate executable file: gradle. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.

Update:

This (last line) seems to workaround the issue (used to work without this):

(you will need to swap /home/.gradle for whatever you $GRADLE_USER_HOME is. )

      - name: Enable actions/cache for Gradle
        uses: gradle/gradle-build-action@a4cf152f482c7ca97ef56ead29bf08bcd953284c # v2.7.0
        with:
          gradle-home-cache-cleanup: true
      - name: Gradle Build
        shell: bash
        run: |
          ./gradlew build
          echo "$(find /home/.gradle/wrapper/dists/ -name gradle | xargs ls -tr | tail -n 1 | xargs dirname)" >> $GITHUB_PATH
bigdaz commented 1 year ago

Thanks @yogurtearl . This looks to be a duplicate of gradle/actions#33. Are you running actions on self-hosted or github-hosted runners? (GitHub hosted runners all seem to have the latest version of Gradle installed and on the PATH).

yogurtearl commented 1 year ago

Yes, this happened when running on a self hosted runner where the machine image does not have gradle installed, and on top of that inside a docker image that does not have gradle installed.

bigdaz commented 1 year ago

OK, closing as a duplicate of gradle/actions#33