On Ubuntu Saucy:
npm can be installed using nvm for the sake of this example. It puts a symbolic link “npm” on the PATH, pointing to a js file.
task npm(type:Exec) {
commandLine ‘npm’ }
This works fine with gradle 1.9, but in 1.10 I get:
- Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:npm’.
Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process ‘command ‘npm’’
at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(DefaultExecHandle.java:192)
at org.gradle.process.internal.DefaultExecHandle.failed(DefaultExecHandle.java:321)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:88)
… 1 more Caused by: java.io.IOException: Cannot run program “npm” (in directory “/home/user/path”): error=2, No such file or directory
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:69)
… 1 more Caused by: java.io.IOException: error=2, No such file or directory
… 2 more
There are 2 issues. The first is that this commands now fails, which is bad enough. But the StackTrace also seems weird and useless (java has no business looking for any file in that directory), so it seems this is some fallback failing. If so, the debug log should indicate that the original call failed.
I can still run shell command like
task npm(type:Exec) {
commandLine ‘ls’, ‘-al’ }
or even
task npm(type:Exec) {
commandLine ‘which’, ‘npm’ }
which returns the path to the executable.