I'm using Spotless with Prettier in a Gradle submodule. (Another submodule also uses Spotless, but with Kotlin.)
My build task will clean the /build directory before starting, as the compiled Javascript resources will end up in there. However, it seems that Spotless first creates a directory spotless-node-modules-prettier-format in /build, which will then get cleaned by the build task, and then the actual spotlessCheck fails quite ugly:
Step 'prettier-format' found problem in 'frontend/src/components/App.tsx':
Failed to launch npm command 'npm start --scripts-prepend-node-path=true'.
com.diffplug.spotless.npm.NpmProcess$NpmProcessException: Failed to launch npm command 'npm start --scripts-prepend-node-path=true'.
at com.diffplug.spotless.npm.NpmProcess.npm(NpmProcess.java:66)
at com.diffplug.spotless.npm.NpmProcess.start(NpmProcess.java:42)
at com.diffplug.spotless.npm.NpmFormatterStepStateBase.npmRunServer(NpmFormatterStepStateBase.java:95)
at com.diffplug.spotless.npm.PrettierFormatterStep$State.createFormatterFunc(PrettierFormatterStep.java:84)
at com.diffplug.spotless.FormatterStepImpl$Standard.format(FormatterStepImpl.java:76)
at com.diffplug.spotless.FormatterStep$Strict.format(FormatterStep.java:76)
at com.diffplug.spotless.Formatter.compute(Formatter.java:230)
at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:201)
at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:188)
at com.diffplug.gradle.spotless.SpotlessTaskImpl.processInputFile(SpotlessTaskImpl.java:71)
at com.diffplug.gradle.spotless.SpotlessTaskImpl.performAction(SpotlessTaskImpl.java:57)
[...]
Caused by: java.io.IOException: Cannot run program "/usr/bin/npm" (in directory "<snip>/frontend/build/spotless-node-modules-prettier-format"): error=2, File or directory not found
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
at com.diffplug.spotless.npm.NpmProcess.npm(NpmProcess.java:64)
... 145 more
Caused by: java.io.IOException: error=2, File or directory not found
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
... 147 more
It seems that this only happens when I run build in more than this submodule.
Can Spotless be made to create that directory not in the configuration phase, but only when it actually runs?
Gradle: 7.0, but also observed with earlier versions
Spotless version: 5.12.4
OS: Latest Manjaro
I'm using Spotless with Prettier in a Gradle submodule. (Another submodule also uses Spotless, but with Kotlin.)
My
buildtask will clean the/builddirectory before starting, as the compiled Javascript resources will end up in there. However, it seems that Spotless first creates a directoryspotless-node-modules-prettier-formatin/build, which will then get cleaned by thebuildtask, and then the actualspotlessCheckfails quite ugly:It seems that this only happens when I run
buildin more than this submodule.Can Spotless be made to create that directory not in the configuration phase, but only when it actually runs?
Gradle: 7.0, but also observed with earlier versions
Spotless version: 5.12.4
OS: Latest Manjaro