Gradle build fail with Cannot run program No such file or directory

Try stopping the gradle daemon with ./gradlew --stop

I had the same problem with something as simple as:

commandLine = [ "node", "--version"]

It came down to the gradle daemon having a cached location of node which no longer existed (I had updated node sometime before).


You shouldn't use commandLine + args together in a Gradle Exec task. Either use commandLine with executable and all arguments as the value, or executable + args which is the better alternative usually.


I had similar issue.. With Vampire's solution, I was able to step up.. However the issue seems to be the sh file not able to point to the exact file location.

Meaning, even with workingDir (wherein actual sh file resides) set properly, still was getting the following exception.

Caused by: java.io.IOException: error=2, No such file or directory

Finally, this post resolved the issue..

Though the original issue of this post's question is already resolved, thought of sharing this solution of adding the absolute file path to actual sh file would resolve the "No such file or directory" issue to someone in the future..

I ran into similar issue and got it resolved with absolute path reference to sh file.

Mine was,

workingDir = "path_to_the_actual_sh_file_to_be_executed"
executable = new File(workingDir, 'actual.sh')
args = ['configure', 'manageRepo', '-tenant', 'etc...']

Tags:

Gradle