Broken output in Exec on Windows

I have a problem with certain output using Exec on Windows. When executing npm list using Exec task the output on Windows is messed up. I have seen this with other commands too. Here’s an example:

task npmList(type: Exec) {
  commandLine 'cmd', '/c', 'npm', 'list'
}

The output on unix (mac):

:npmList
example@1.1.1 /Volumes/C/Users/srs/Desktop/workspace
└─┬ safefs@3.1.1
  └── graceful-fs@2.0.3

When running on windows using the standard command shell:

:npmList
example@1.1.1 C:\Users\srs\Desktop\workspace
Γö£ΓöÇΓöÇ graceful-fs@2.0.3
ΓööΓöÇΓöÇ safefs@3.1.1

When running npm list directly on windows:

example@1.1.1 /Volumes/C/Users/srs/Desktop/workspace
└─┬ safefs@3.1.1
  └── graceful-fs@2.0.3

If I use the Java ProcessBuilder directly then it works just fine. It seems to me that it has something to do with StreamsForwarder used in AbstractExecHandleBuilder.

Any idea on how to fix this?

BR,
Sten Roger

I think you might be seeing this: https://issues.gradle.org/browse/GRADLE-3329

1 Like

GRADLE-3329 has been fixed by https://github.com/gradle/gradle/commit/1746300a . This will be included in 3.2-rc-1 .