Skip to content
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

Corrupt serialized resolution result/Problems reading from Binary store when executing dependencies tasks or build scans #14220

Open
tjuricek-vmware opened this issue Aug 19, 2020 · 36 comments
Assignees
Labels
Milestone

Comments

@tjuricek-vmware
Copy link

When executing ./gradlew dependencies --write-locks, the build fails with this error:

integrationStubImplementation - Implementation only dependencies for compilation 'integrationStub' (target  (jvm)).

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dependencies'.
> Could not resolve all dependencies for configuration ':integrationStubImplementation'.
   > Problems reading data from Binary store in /tmp/gradle15135648821751580614.bin offset 221374 exists? true

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 3s
1 actionable task: 1 executed

When attempting to generate ./gradlew dependencies --scan, I receive this output:


> Task :dependencies FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dependencies'.
> Could not resolve all dependencies for configuration ':integrationStubImplementation'.
   > Problems reading data from Binary store in /tmp/gradle13858920095948672727.bin offset 261444 exists? true

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 31s
1 actionable task: 1 executed

A build scan cannot be produced as an error occurred gathering build data.
Please report this problem via https://gradle.com/help/plugin and include the following via copy/paste:

----------
Gradle version: 6.6
Plugin version: 3.4

org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':integrationStubImplementation'.
        at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.wrapException(ErrorHandlingConfigurationResolver.java:104)
        at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.access$000(ErrorHandlingConfigurationResolver.java:48)
        at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver$ErrorHandlingResolutionResult.getRoot(ErrorHandlingConfigurationResolver.java:203)
        at org.gradle.api.internal.artifacts.configurations.ResolveConfigurationResolutionBuildOperationResult.getRootComponent(ResolveConfigurationResolutionBuildOperationResult.java:59)
        at com.gradle.scan.plugin.internal.b.f.a.h$a.b(SourceFile:116)
        at com.gradle.scan.plugin.internal.b.f.a.h$a.a(SourceFile:70)
        at com.gradle.scan.plugin.internal.b.f.a.h.a(SourceFile:51)
        at com.gradle.scan.plugin.internal.b.f.a.g.a(SourceFile:149)
        at com.gradle.scan.plugin.internal.b.f.c.a(SourceFile:135)
        at com.gradle.scan.plugin.internal.j.a.f.a(SourceFile:12)
        at com.gradle.scan.plugin.internal.j.a$c.finished(SourceFile:154)
        at com.gradle.scan.plugin.internal.j.a.a(SourceFile:65)
        at com.gradle.scan.plugin.internal.j.k.a(SourceFile:58)
        at com.gradle.scan.plugin.internal.j.c.a(SourceFile:103)
        at com.gradle.scan.plugin.internal.j.g.a(SourceFile:48)
        at com.gradle.scan.plugin.internal.q.a$a.a(SourceFile:31)
        at com.gradle.scan.plugin.internal.q.a$a.a(SourceFile:20)
        at com.gradle.scan.plugin.internal.q.a.c(SourceFile:67)
Caused by: java.lang.RuntimeException: Problems reading data from Binary store in /tmp/gradle13858920095948672727.bin offset 261444 exists? true
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.DefaultBinaryStore$SimpleBinaryData.read(DefaultBinaryStore.java:132)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.StreamingResolutionResultBuilder$RootFactory.lambda$create$0(StreamingResolutionResultBuilder.java:187)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.CachedStoreFactory$SimpleStore.load(CachedStoreFactory.java:101)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.StreamingResolutionResultBuilder$RootFactory.create(StreamingResolutionResultBuilder.java:185)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.StreamingResolutionResultBuilder$RootFactory.create(StreamingResolutionResultBuilder.java:157)
        at org.gradle.api.internal.artifacts.result.DefaultResolutionResult.getRoot(DefaultResolutionResult.java:48)
        at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver$ErrorHandlingResolutionResult.getRoot(ErrorHandlingConfigurationResolver.java:201)
        at org.gradle.api.internal.artifacts.configurations.ResolveConfigurationResolutionBuildOperationResult.getRootComponent(ResolveConfigurationResolutionBuildOperationResult.java:59)
        at com.gradle.scan.plugin.internal.b.f.a.h$a.b(SourceFile:116)
        at com.gradle.scan.plugin.internal.b.f.a.h$a.a(SourceFile:70)
        at com.gradle.scan.plugin.internal.b.f.a.h.a(SourceFile:51)
        at com.gradle.scan.plugin.internal.b.f.a.g.a(SourceFile:149)
        at com.gradle.scan.plugin.internal.b.f.c.a(SourceFile:135)
        at com.gradle.scan.plugin.internal.j.a.f.a(SourceFile:12)
        at com.gradle.scan.plugin.internal.j.a$c.finished(SourceFile:154)
        at com.gradle.scan.plugin.internal.j.a.a(SourceFile:65)
        at com.gradle.scan.plugin.internal.j.k.a(SourceFile:58)
        at com.gradle.scan.plugin.internal.j.c.a(SourceFile:103)
        at com.gradle.scan.plugin.internal.j.g.a(SourceFile:48)
        at com.gradle.scan.plugin.internal.q.a$a.a(SourceFile:31)
        at com.gradle.scan.plugin.internal.q.a$a.a(SourceFile:20)
        at com.gradle.scan.plugin.internal.q.a.c(SourceFile:67)
Caused by: java.lang.IllegalStateException: Corrupt serialized resolution result. Cannot find selected module (889) for constraint integrationStubImplementation -> com.vmware.carbonblackcloud:exekute:1.0.0
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.DefaultResolutionResultBuilder.visitOutgoingEdges(DefaultResolutionResultBuilder.java:82)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.StreamingResolutionResultBuilder$RootFactory.deserialize(StreamingResolutionResultBuilder.java:237)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.DefaultBinaryStore$SimpleBinaryData.read(DefaultBinaryStore.java:130)
        ... 21 more
----------

Could this be a weird local dependency problem?

Also, I did successfully run ./gradlew classes --update-locks com.vmware.carbonblackcloud:exekute. So I'm not 100% sure if that's just a red herring here or not.

Expected Behavior

I would like for all of my dependencies to resolve, basically, or flag an actionable error that indicates what is the problem on my end.

Current Behavior

See the above output, it's pretty much "I can't update my lockfiles using the global command".

Context

We're using version locking, and I have several libraries I'm using, and I want to update all dependencies, to look for updates, typically to the AWS library.

Steps to Reproduce

This is challenging, because it's in a project with a whole bunch of company IP. And I can't provide a build scan for this task since that part fails, though I'm game for adding any other tasks, debugging, etc., though I bet the debug output would be ok.

Your Environment

Linux (Ubuntu 18.04), using JDK 14.0.2, and Gradle 6.6.

@tjuricek-vmware
Copy link
Author

This morning, I actually removed that internal project, exekute that was listed in the build scan output, and removed some kotlin dependencies from the project. The scan still fails, but with a publicly available POM:

BUILD FAILED in 28s
1 actionable task: 1 executed

A build scan cannot be produced as an error occurred gathering build data.
Please report this problem via https://gradle.com/help/plugin and include the following via copy/paste:

----------
Gradle version: 6.6
Plugin version: 3.4

org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':integrationStubImplementation'.
        at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.wrapException(ErrorHandlingConfigurationResolver.java:104)
        at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.access$000(ErrorHandlingConfigurationResolver.java:48)
        at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver$ErrorHandlingResolutionResult.getRoot(ErrorHandlingConfigurationResolver.java:203)
        at org.gradle.api.internal.artifacts.configurations.ResolveConfigurationResolutionBuildOperationResult.getRootComponent(ResolveConfigurationResolutionBuildOperationResult.java:59)
        at com.gradle.scan.plugin.internal.b.f.a.h$a.b(SourceFile:116)
        at com.gradle.scan.plugin.internal.b.f.a.h$a.a(SourceFile:70)
        at com.gradle.scan.plugin.internal.b.f.a.h.a(SourceFile:51)
        at com.gradle.scan.plugin.internal.b.f.a.g.a(SourceFile:149)
        at com.gradle.scan.plugin.internal.b.f.c.a(SourceFile:135)
        at com.gradle.scan.plugin.internal.j.a.f.a(SourceFile:12)
        at com.gradle.scan.plugin.internal.j.a$c.finished(SourceFile:154)
        at com.gradle.scan.plugin.internal.j.a.a(SourceFile:65)
        at com.gradle.scan.plugin.internal.j.k.a(SourceFile:58)
        at com.gradle.scan.plugin.internal.j.c.a(SourceFile:103)
        at com.gradle.scan.plugin.internal.j.g.a(SourceFile:48)
        at com.gradle.scan.plugin.internal.q.a$a.a(SourceFile:31)
        at com.gradle.scan.plugin.internal.q.a$a.a(SourceFile:20)
        at com.gradle.scan.plugin.internal.q.a.c(SourceFile:67)
Caused by: java.lang.RuntimeException: Problems reading data from Binary store in /tmp/gradle1615510607535013790.bin offset 220456 exists? true
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.DefaultBinaryStore$SimpleBinaryData.read(DefaultBinaryStore.java:132)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.StreamingResolutionResultBuilder$RootFactory.lambda$create$0(StreamingResolutionResultBuilder.java:187)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.CachedStoreFactory$SimpleStore.load(CachedStoreFactory.java:101)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.StreamingResolutionResultBuilder$RootFactory.create(StreamingResolutionResultBuilder.java:185)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.StreamingResolutionResultBuilder$RootFactory.create(StreamingResolutionResultBuilder.java:157)
        at org.gradle.api.internal.artifacts.result.DefaultResolutionResult.getRoot(DefaultResolutionResult.java:48)
        at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver$ErrorHandlingResolutionResult.getRoot(ErrorHandlingConfigurationResolver.java:201)
        at org.gradle.api.internal.artifacts.configurations.ResolveConfigurationResolutionBuildOperationResult.getRootComponent(ResolveConfigurationResolutionBuildOperationResult.java:59)
        at com.gradle.scan.plugin.internal.b.f.a.h$a.b(SourceFile:116)
        at com.gradle.scan.plugin.internal.b.f.a.h$a.a(SourceFile:70)
        at com.gradle.scan.plugin.internal.b.f.a.h.a(SourceFile:51)
        at com.gradle.scan.plugin.internal.b.f.a.g.a(SourceFile:149)
        at com.gradle.scan.plugin.internal.b.f.c.a(SourceFile:135)
        at com.gradle.scan.plugin.internal.j.a.f.a(SourceFile:12)
        at com.gradle.scan.plugin.internal.j.a$c.finished(SourceFile:154)
        at com.gradle.scan.plugin.internal.j.a.a(SourceFile:65)
        at com.gradle.scan.plugin.internal.j.k.a(SourceFile:58)
        at com.gradle.scan.plugin.internal.j.c.a(SourceFile:103)
        at com.gradle.scan.plugin.internal.j.g.a(SourceFile:48)
        at com.gradle.scan.plugin.internal.q.a$a.a(SourceFile:31)
        at com.gradle.scan.plugin.internal.q.a$a.a(SourceFile:20)
        at com.gradle.scan.plugin.internal.q.a.c(SourceFile:67)
Caused by: java.lang.IllegalStateException: Corrupt serialized resolution result. Cannot find selected module (1650) for constraint platform-runtime -> com.rabbitmq:amqp-client:5.9.0
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.DefaultResolutionResultBuilder.visitOutgoingEdges(DefaultResolutionResultBuilder.java:82)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.StreamingResolutionResultBuilder$RootFactory.deserialize(StreamingResolutionResultBuilder.java:237)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.DefaultBinaryStore$SimpleBinaryData.read(DefaultBinaryStore.java:130)
        ... 21 more
----------

I'm still zeroing in on what triggers this. I think it may be a platform dependency in a custom source set.

@tjuricek-vmware
Copy link
Author

I've only ironed out that it only occurs when the --write-locks option is enabled for the dependencies task. I've had to disable version locking, and everything resolves now.

@tjuricek-vmware
Copy link
Author

Today I went through, and eventually figured out there were three transitive dependencies that had to be declared as implementation dependencies in the main source set, and that bypassed the resolution problems. I can't for the life of me, understand what these had to do with anything, I suspect it's just a hidden timing issue.

It makes no sense otherwise that these dependencies would have caused any particular harm:

implementation("com.rabbitmq:amqp-client:5.9.0")
implementation("net.bytebuddy:byte-buddy-agent:1.10.13")
implementation("commons-logging:commons-logging:1.1.3")

I'll also note: we are using an internal artifactory server to both cache maven central deps (and where we host internal projects). I'm not seeing anything weird with it, so I really am not sure if it's somehow also causing issues.

@ljacomet
Copy link
Member

Thanks for the report and attempts at reproducing.

These issues are usually caused by corner cases in the dependency graph computation. That's why changing declaration order or adding / removing dependencies can make the problem go away.
Unfortunately, these issues are hard to track without an isolated reproducer.

#14229 fixes such a corner case. Once a nightly with the fix is available, I'll ask you to test it to see if it fixes this issue.

@ljacomet
Copy link
Member

Can you try with a nightly and let us know how it goes?
https://gradle.org/nightly/

@tjuricek-vmware
Copy link
Author

No, unfortunately it still had a problem:

Caused by: java.lang.IllegalStateException: Corrupt serialized resolution result. Cannot find selected module (1345) for constraint platform-runtime -> com.rabbitmq:amqp-client:5.9.0
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.DefaultResolutionResultBuilder.visitOutgoingEdges(DefaultResolutionResultBuilder.java:83)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.StreamingResolutionResultBuilder$RootFactory.deserialize(StreamingResolutionResultBuilder.java:238)
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.DefaultBinaryStore$SimpleBinaryData.read(DefaultBinaryStore.java:130)
        ... 113 more

This was using this version:

$ ./gradlew --version

------------------------------------------------------------
Gradle 6.7-20200824220048+0000
------------------------------------------------------------

Build time:   2020-08-24 22:00:48 UTC
Revision:     1c64c1d968445857daf8b3d630f22d20b938fce8

Kotlin:       1.3.72
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM:          14.0.2 (Oracle Corporation 14.0.2+12-46)
OS:           Linux 5.4.0-42-generic amd64

@melix
Copy link
Contributor

melix commented Sep 14, 2020

Unfortunately we can't figure out what's going on without a reproducer, as it's a particularly difficult thing to debug. We'd appreciate if you can trip down your project/anonymize to a minimal reproducer.

@tjuricek-vmware
Copy link
Author

Unfortunately, we have a lot of internal dependencies here (with different build approaches, etc), and figuring out a reproduction case wasn't getting anywhere quickly.

What I may end up doing is learning how to actually build/debug Gradle itself, so I can just locally debug this. But that's not exactly my highest priority, so I can't you when I'd get around to this.

Basically, I think it's probably valid to just say "can't reproduce" and close this issue. If I actually am able to figure out what's going on, I'll re-open it with reproduction details, or reference a new ticket with a reproduction case.

@shmish111
Copy link

I just had the same problem but with org.postgresql:postgresql. I added an explicit implementation dependency and that fixed things, very weird

@ljacomet
Copy link
Member

@shmish111 Any chance that you are using replacement rules?
We are about to fix an issue for Gradle 7.3 rooted in replacement rules that ends up causing this kind of problems.
See #18079

@shmish111
Copy link

Not that I'm aware of but I will try to remember to try this out once that is released.

@ljacomet
Copy link
Member

Gradle 7.3 RC1 is out already, could you check with that version?

@rupebac
Copy link

rupebac commented Dec 14, 2021

Having this problem even with 7.3.1

@ljacomet ljacomet self-assigned this Dec 14, 2021
@shivkumar138
Copy link

`----------
Gradle version: 6.9.2
Plugin version: 3.7.1

org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':ads-engagement-summary-report-job-azkaban_2.11:compileClasspath'.
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.wrapException(ErrorHandlingConfigurationResolver.java:106)
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.access$000(ErrorHandlingConfigurationResolver.java:49)
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver$ErrorHandlingResolutionResult.getRoot(ErrorHandlingConfigurationResolver.java:215)
at org.gradle.api.internal.artifacts.configurations.ResolveConfigurationResolutionBuildOperationResult.getRootComponent(ResolveConfigurationResolutionBuildOperationResult.java:59)
at com.gradle.scan.plugin.internal.b.f.a.h$a.b(SourceFile:113)
at com.gradle.scan.plugin.internal.b.f.a.h$a.a(SourceFile:66)
at com.gradle.scan.plugin.internal.b.f.a.h.a(SourceFile:47)
at com.gradle.scan.plugin.internal.b.f.a.g.a(SourceFile:147)
at com.gradle.scan.plugin.internal.b.f.c.a(SourceFile:137)
at com.gradle.scan.plugin.internal.l.a.f.a(SourceFile:12)
at com.gradle.scan.plugin.internal.l.a$c.finished(SourceFile:154)
at com.gradle.scan.plugin.internal.l.a.a(SourceFile:65)
at com.gradle.scan.plugin.internal.l.l.a(SourceFile:58)
at com.gradle.scan.plugin.internal.l.c.a(SourceFile:98)
at com.gradle.scan.plugin.internal.l.g.a(SourceFile:51)
at com.gradle.scan.plugin.internal.q.a$a.a(SourceFile:31)
at com.gradle.scan.plugin.internal.q.a$a.a(SourceFile:20)
at com.gradle.scan.plugin.internal.q.a.c(SourceFile:67)
Caused by: java.lang.RuntimeException: Problems reading data from Binary store in /private/var/folders/ft/b5jkwn010tj3llqw2ljgx1h0001dc1/T/gradle6382969199485670936.bin offset 682978 exists? true
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.DefaultBinaryStore$SimpleBinaryData.read(DefaultBinaryStore.java:132)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.StreamingResolutionResultBuilder$RootFactory.lambda$create$0(StreamingResolutionResultBuilder.java:189)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.CachedStoreFactory$SimpleStore.load(CachedStoreFactory.java:101)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.StreamingResolutionResultBuilder$RootFactory.create(StreamingResolutionResultBuilder.java:187)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.StreamingResolutionResultBuilder$RootFactory.create(StreamingResolutionResultBuilder.java:159)
at org.gradle.api.internal.artifacts.result.DefaultResolutionResult.getRoot(DefaultResolutionResult.java:48)
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver$ErrorHandlingResolutionResult.getRoot(ErrorHandlingConfigurationResolver.java:213)
at org.gradle.api.internal.artifacts.configurations.ResolveConfigurationResolutionBuildOperationResult.getRootComponent(ResolveConfigurationResolutionBuildOperationResult.java:59)
at com.gradle.scan.plugin.internal.b.f.a.h$a.b(SourceFile:113)
at com.gradle.scan.plugin.internal.b.f.a.h$a.a(SourceFile:66)
at com.gradle.scan.plugin.internal.b.f.a.h.a(SourceFile:47)
at com.gradle.scan.plugin.internal.b.f.a.g.a(SourceFile:147)
at com.gradle.scan.plugin.internal.b.f.c.a(SourceFile:137)
at com.gradle.scan.plugin.internal.l.a.f.a(SourceFile:12)
at com.gradle.scan.plugin.internal.l.a$c.finished(SourceFile:154)
at com.gradle.scan.plugin.internal.l.a.a(SourceFile:65)
at com.gradle.scan.plugin.internal.l.l.a(SourceFile:58)
at com.gradle.scan.plugin.internal.l.c.a(SourceFile:98)
at com.gradle.scan.plugin.internal.l.g.a(SourceFile:51)
at com.gradle.scan.plugin.internal.q.a$a.a(SourceFile:31)
at com.gradle.scan.plugin.internal.q.a$a.a(SourceFile:20)
at com.gradle.scan.plugin.internal.q.a.c(SourceFile:67)
Caused by: java.lang.IllegalStateException: Corrupt serialized resolution result. Cannot find selected module (2241) for default -> com.linkedin.container-core:container-ic-impl:1.2.14
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.DefaultResolutionResultBuilder.visitOutgoingEdges(DefaultResolutionResultBuilder.java:83)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.StreamingResolutionResultBuilder$RootFactory.deserialize(StreamingResolutionResultBuilder.java:239)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.DefaultBinaryStore$SimpleBinaryData.read(DefaultBinaryStore.java:130)
... 21 more
`

Cannot do a successful build anymore after this.

@jacky1234
Copy link

I have the same problem

@ljacomet
Copy link
Member

Some more fixes have landed on the main branch recently.
Can you try with a nightly?

@jjohannes
Copy link
Contributor

jjohannes commented Oct 19, 2022

Here is a reproducer for the problem in an error case when dynamic versions are involved.
(checked with 7.4.2, 7.5.1 and latest 8.0 nightly)

reproducer-14220.zip

In the attached example:

  • Run gradle resolveArtifacts to get a proper error:
Execution failed for task ':resolveArtifacts'.
> Could not resolve all files for configuration ':implementation'.
   > Could not find any version that matches test:module1:11.2.0.+.
     Versions that do not match: 11.1.0.1
     Searched in the following locations:
       - file:/C:/SPU/pwe/tkeasy/default/git-repos/gradle-plugins/reproducer-14220/repo/test/module1/maven-metadata.xml
     Required by:
         project :
  • Run gradle dependencies, or any build with --scan, and you get
> Could not resolve all dependencies for configuration ':implementation'.
   > Problems reading data from Binary store in .gradle\.tmp\gradle2620150027837008206.bin offset 0 exists? true
...
  Corrupt serialized resolution result. Cannot find selected module (8) for constraint runtimeElements -> test:module1:11.1.0.1

This is also a problem if you write tasks that take resolution results with errors as input (using configuration.getIncoming().getResolutionResult().getRootComponent() as task input). Instead of getting a proper result to inspect the error, the build fails.

A workaround to at least keep the build working (with an empty resolution result though) is to use the following as task input:

project.provider(() -> {
  try {
    return configuration.getIncoming().getResolutionResult().getRootComponent().get();
  } catch (ResolveException e) {
    project.getLogger().lifecycle("Bug https://github.com/gradle/gradle/issues/14220");
    project.getLogger().lifecycle(e.getCause().getCause().getMessage());
    // empty result
    return project.getConfigurations().detachedConfiguration().getIncoming().getResolutionResult().getRootComponent().get();
  }
});

@jjohannes
Copy link
Contributor

Another reproducer, this time for a successful resolution:

@NielsDoucet
Copy link
Contributor

We had this issue trigger because of the following dependency substitution rule:

module("org.hamcrest:hamcrest-core") {
    replacedBy("org.hamcrest:hamcrest", "`hamcrest-core` migrated to `hamcrest`")
}

Due to the project's upgrade strategy using shim jars (see https://hamcrest.org/JavaHamcrest/distributables#previous-versions-of-hamcrest), hamcrest-core now depends on hamcrest.
It seems using replacement rules triggers corruption of the serialised dependency graph in this case.

@jbretsch
Copy link

gradle-problems-reading-binary-store also reproduces the problem. There, the problem disappears by switching the order of the only two dependencies declared in the build.gradle.

@mathjeff
Copy link
Contributor

Any ideas about things that users might be able to do to help out with this?

@marcellogalhardo
Copy link

I'm facing an issue while working on converting the AndroidX library lifecycle-viewmodel-compose to Kotlin Multiplatform. The problem appears to be related to the library being KMP, with the Android source set depending on livedata-core (Java).

For reference, here are the AOSP changes:

@mathjeff
Copy link
Contributor

We think we found a workaround in the case of the previous comment, which is to explicitly add a transitive dependency to the androidMain sourceset from the project encountering the error (:lifecycle:lifecycle-viewmodel-compose) to the project providing the artifact that failed to resolve (:lifecycle:lifecycle-livedata-core).

Also interesting, if we instead add the transitive dependency to the commonMain sourceset instead, then we get a resolution ambiguity error

copybara-service bot pushed a commit to androidx/androidx that referenced this issue Mar 27, 2024
* Converting `lifecycle-viewmodel-compose` to Kotlin Multiplatform, and transitively depending on `lifecycle-livedata-core` triggered a bug in Gradle (gradle/gradle#14220).
* Directly adding `lifecycle-livedata-core` to `androidMain` allowed us to workaround the issue.

Test: `./gradlew :lifecycle:lifecycle-viewmodel-compose:compileCommonMainKotlinMetadata -Pandroidx.constraints=true`
Bug: 330323282
Change-Id: I0eb4c79efeb65e049f51706c6dcefce0d1ab83a4
copybara-service bot pushed a commit to androidx/androidx that referenced this issue Mar 29, 2024
* `compose-ui` has a transitive dependency on `lifecycle-livedata-core`, and converting `lifecycle-runtime-compose` to KMP triggered a Gradle bug (gradle/gradle#14220).
* Directly adding `lifecycle-livedata-core` as `compileOnly` to `androidMain` allowed us to workaround the issue.

Test: `./gradlew :compose:ui:ui:compileCommonMainKotlinMetadata -Pandroidx.constraints=true`
Bug: 331769623
Change-Id: I463276189cf90cfca8efc46bb29ecbb64010e09e
copybara-service bot pushed a commit to androidx/androidx that referenced this issue Mar 29, 2024
* `compose-ui` has a transitive dependency on `lifecycle-viewmodel-savedstate`, and converting `lifecycle-runtime-compose` to KMP triggered a Gradle bug (gradle/gradle#14220). Adding the `livedata` dependency directly works around the issue.
* Directly adding `lifecycle-viewmodel-savedstate` as `compileOnly` to `androidMain` allowed us to workaround the issue.

Test: `./gradlew :compose:ui:ui:compileCommonMainKotlinMetadata -Pandroidx.constraints=true`
Bug: 331769623
Change-Id: Ic4f81fe2737b3d61fd9b4cb02a8b940e3a0d4caf
@jvandort jvandort modified the milestones: 8.9 RC1, 8.10 RC1 May 28, 2024
@jvandort
Copy link
Member

jvandort commented Jul 8, 2024

Thank you all for your patience on this issue. We have been working hard on these reported problems, many of which are quite complex and trigger edge cases in the resolution engine.

We have a PR, #29853, which should resolve a number of the problematic builds reported in this thread. Unfortunately, since the corrupt resolution result error message is a symptom and not a problem itself, this message can appear as a result of different bugs. The linked PR does not solve all the problems reported here.

We will continue to work through the reproducers submitted here until there are no outstanding issues that cause corrupt graphs. Correctness and stability are a very high priority for Gradle, and we intend to ensure these issues are resolved.

@jvandort
Copy link
Member

jvandort commented Jul 8, 2024

@marcellogalhardo it seems both links you posted require internal google sign-on

@mathjeff Is this the same underlying issue as #26145 (comment)?

@mathjeff
Copy link
Contributor

mathjeff commented Jul 9, 2024

I think this is the same as #26145 (comment), yeah.

Thanks!

@jvandort jvandort modified the milestones: 8.10 RC1, 8.11 RC1 Jul 18, 2024
@jvandort
Copy link
Member

Unfortunately the above linked PR has been reverted due to a regression it introduced. The fix will not be included with Gradle 8.10. We will work to include the change in 8.11

@jvandort jvandort modified the milestones: 8.11 RC1, 8.12 RC1 Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests