New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gradle crashes if GRADLE_RO_DEP_CACHE is set and it cannot create modules-2 directory within it #12293
Comments
Thanks for the report. Maybe it's unclear but the shared read-only directory should always be pre-populated. You mustn't have one build with write access to it and others with read-access: all builds must have read-only access so don't let any Gradle build write directly to it. |
Thank you. The requirement for having it pre-populated was not clear to me from the documentation. |
Explicit notes have been added to the documentation to clarify the need of having a populated read-only cache. |
I ran into the same issue and I still think it's bad that Gradle crashes if the directory is empty. This directory is always read-only. This is even reflected by the property name. So I don't see why Gradle should ever even attempt to write to it (by attempting to create directories). I think Gradle should just behave as if the property hasn't been set (maybe logging a warning or info) if the directory is empty, doesn't exist at all or cannot be used for any other reason. My use case: I tried to define "GRADLE_RO_DEP_CACHE" at the Jenkins system configuration, making it available to all builds. This works fine for all builds running directly on the host, but unfortunately, this immediately caused all builds that are executed inside a docker container to fail. I really think Gradle should just swallow a non-existing (sub)directory in this case. |
That's a fair point. Let us work on fixing that for the next release. |
-1 to silently failing. This indicates a mis-configuration. It's important to fix the configuration problem. We can avoid crashing, but we shouldn't silence problems. |
Of course I agree with you! This was badly worded on my part. By "swallowing" I just meant "not crashing". A log message is perfectly adequate for this situation. |
Hi folks, Gradle version used: 6.2.1 |
Hey @prakashul , Could you share more specific information about what you tried exactly?
For example, this would be a valid setup:
|
Hi @ljacomet Thanks for clearing that up, the solution worked. By your example, i had copied /users/foo/.gradle/caches to a new location. Thanks :) |
Expected Behavior
If the GRADLE_RO_DEP_CACHE is set, the build should never fail because it cannot be written to.
Current Behavior
When I create a directory for the shared read-only cache, and make it available as an empty read-only directory, with no modules-2 subdirectory present, the build crashes when it tries to create the modules-2 subdirectory.
Please find the full failure report including stacktrace in the attached file.
Context
I'm using Jenkins 2 with builds occurring in ephemeral containers. Using directories mapped from the host server into the container for the read-only dependency cache.
The goal is to minimise the required downloads and the build time increases caused by those downloads.
My current workaround for this issue is the pre-create the modules-2 directory, but that will cause a failure if Gradle ever moves to a modules-3 version.
Steps to Reproduce
Please run the following script to reproduce:
Your Environment
Gradle 6.2
Running on Linux in docker container, or MacOS 10.15.3 locally.
The text was updated successfully, but these errors were encountered: