gradle icon indicating copy to clipboard operation
gradle copied to clipboard

configuration cache with included build causes --profile unable to create directory

Open mathjeff opened this issue 4 years ago • 10 comments

Expected Behavior

If I run a build that uses an included build, has configuration caching enabled, and uses the --profile argument, I'd like the process of generating the profile report to succeed.

Current Behavior

Currently if I do the above, I observe that Gradle says it cannot create the report directory:

Could not stop build 'doclava'.
org.gradle.api.UncheckedIOException: Could not write to file 'reports/profile/profile-1969-12-31-19-00-00.html'.
	at org.gradle.internal.IoActions$TextFileWriterIoAction.execute(IoActions.java:152)
	at org.gradle.internal.IoActions$TextFileWriterIoAction.execute(IoActions.java:127)
	at org.gradle.internal.IoActions.writeTextFile(IoActions.java:45)
...
Caused by: java.io.IOException: Unable to create directory 'reports/profile'
	at org.gradle.internal.IoActions$TextFileWriterIoAction.execute(IoActions.java:142)

Context

This makes it slightly more difficult to enable configuration caching in androidx ( https://android.googlesource.com/platform/frameworks/support/ )

Steps to Reproduce

See https://github.com/mathjeff/gradle-samples/tree/master/included-build-configuration-cache-profile

Your Environment

Build scan URL: https://scans.gradle.com/s/22l2n2jlpv5ac

Note that the failure is in generating the profile report file, which happens after publishing the build scan, and so the build scan might not mention the failure to create the profile report file

mathjeff avatar Sep 23 '21 15:09 mathjeff

Also interesting, if I run mkdir reports, that seems to cause the build to succeed

mathjeff avatar Sep 23 '21 15:09 mathjeff

It seems that in this situation, Gradle is trying to put the reports into ./reports whereas it would be nice for them to go into something more like ${rootProject.buildDir}/reports

mathjeff avatar Sep 23 '21 16:09 mathjeff

I'm seeing this same problem in another script where i run the profile multiple times.

I think the real issue in my case is the date 1969-12-31-19-00-00 seems like maybe it is unable to read the date properly? (also, it happens in the second invocation).

A build scan was not published as you have not authenticated with server 'ge.androidx.dev'.
Configuration cache entry stored with 11 problems.
run #1 of 10
Executing ./gradlew --init-script /home/yboyar/src/androidx-main/frameworks/support/room/scripts/rerun-requested-task-init-script.gradle --profile :room:integration-tests:room-testapp-kotlin:kspWithKspDebugAndroidTestKotlin
result: file:///home/yboyar/src/androidx-main/frameworks/support/playground-common/playground-plugin/build/reports/profile/profile-2021-11-29-09-19-22.html file:///home/yboyar/src/androidx-main/frameworks/support/out/room-playground/room-playground/build/reports/profile/profile-2021-11-29-09-19-22.html
total time spent for in this run  file:///home/yboyar/src/androidx-main/frameworks/support/out/room-playground/room-playground/build/reports/profile/profile-2021-11-29-09-19-22.html: 0
run #2 of 10
Executing ./gradlew --init-script /home/yboyar/src/androidx-main/frameworks/support/room/scripts/rerun-requested-task-init-script.gradle --profile :room:integration-tests:room-testapp-kotlin:kspWithKspDebugAndroidTestKotlin
Could not stop build ':'.
org.gradle.api.UncheckedIOException: Could not write to file 'reports/profile/profile-1969-12-31-16-00-00.html'.

yigit avatar Nov 29 '21 17:11 yigit

FWIW, in the IntelliJ debugger, I see that the canonical path for 'reports/profile' resolves to '~/.gradle/daemon/7.4.2/reports/profile' and the mkdirs() call below fails with the exception.

                File parentFile = file.getParentFile();
                if (parentFile != null) {
                    if (!parentFile.mkdirs() && !parentFile.isDirectory()) {
                        throw new IOException(String.format("Unable to create directory '%s'", parentFile));
                    }
                }

sandipchitale avatar Apr 29 '22 04:04 sandipchitale

same question

RicardoJiang avatar Aug 24 '22 04:08 RicardoJiang

Same here

Gozdeee1 avatar Aug 25 '22 12:08 Gozdeee1

same question +1

klboke avatar Jan 10 '23 03:01 klboke

Hi, same here. But I created reports/profile manually in the folder where I run ./gradlew from. So the report was successfully created, though Gradle reported it was created in ~/.gradle/daemon/7.6/reports/profile/profile-1969-12-31-20-00-00.html

Any ideas?

VitalyVPinchuk avatar Feb 07 '23 19:02 VitalyVPinchuk

Still same issue today using gradle 8.3

jandry avatar Sep 25 '23 14:09 jandry

Likewise with Gradle 8.6

franckrasolo avatar Feb 20 '24 10:02 franckrasolo

With reports directory exist, this error could be avoided, but it seems the report content also not correct.

CleanShot 2024-03-06 at 09 31 15@2x

esafirm avatar Mar 06 '24 02:03 esafirm