In gradle tasks of type Exec, why do commandLine and executable behave differently?

When using the commandLine, you need to split the string on spaces, else the executable becomes ruby -v, instead of ruby.

So try this instead:

task checkRubyVersionExecute(type: Exec) {
  commandLine 'ruby', '-v'
}

See the code here to see how the Exec task handles this.

Leave a Comment