actions icon indicating copy to clipboard operation
actions copied to clipboard

Cache cleanup fails with "Unable to locate executable file: gradle" when Gradle is not pre-installed on runner

Open ashirman opened this issue 2 years ago • 10 comments

Our gradle action config looks as the following

    - name: Setup Gradle
      uses: gradle/[email protected]
      with:
        gradle-version: wrapper
        gradle-home-cache-cleanup: true
        cache-read-only: false

so assumption is that in post-action gradle will clean up cache in home directory thanks to gradle-home-cache-cleanup: true. Actually in Post Setup Gradle I see the following message

Post job cleanup.
In final post-action step, saving state and writing summary
Stopping all Gradle daemons before saving Gradle User Home state
Stopping Gradle daemons for /home/runner/.gradle/wrapper/dists/gradle-7.4.[2](https://github.com/pleo-io/triton/runs/8232662390?check_suite_focus=true#step:43:2)-bin/48ivgl02cpt2ed[3](https://github.com/pleo-io/triton/runs/8232662390?check_suite_focus=true#step:43:3)fh9dbalvx8/gradle-7.[4](https://github.com/pleo-io/triton/runs/8232662390?check_suite_focus=true#step:43:4).2
/home/runner/.gradle/wrapper/dists/gradle-7.4.2-bin/48ivgl02cpt2ed3fh9dbalvx8/gradle-7.4.2/bin/gradle --stop
Stopping Daemon(s)
1 Daemon stopped
Forcing cache cleanup.
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.
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.
    at Object.<anonymous> (/home/runner/work/_actions/gradle/gradle-build-action/v2.3.0/dist/webpack:/gradle-build-action/node_modules/@actions/io/lib/io.js:213:1)
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/_actions/gradle/gradle-build-action/v2.3.0/dist/webpack:/gradle-build-action/node_modules/@actions/io/lib/io.js:24:1)

based on sources https://github.com/gradle/gradle-build-action/blob/main/src/cache-cleaner.ts I see as if dummy gradle project does actual clean up. But from where this project should get gradle to execute this

        await exec.exec(`gradle -g ${this.gradleUserHome} --no-daemon --build-cache --no-scan --quiet noop`, [], {
            cwd: cleanupProjectDir
        })

?

Would you please clarify how to properly configure gradle-home-cache-cleanup so it would get gradle from somewhere. Thanks!

ashirman avatar Sep 07 '22 16:09 ashirman