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

Latest-wins conflict resolution rules #1284

Closed
eed3si9n opened this issue Jul 22, 2019 · 3 comments

Comments

@eed3si9n
Copy link
Contributor

commented Jul 22, 2019

steps

eed3si9n/lagom-samples@6f5bd56

problem

https://travis-ci.org/eed3si9n/lagom-samples/jobs/562204770

[error] lmcoursier.internal.shaded.coursier.error.ResolutionError$ConflictingDependencies: Conflicting dependencies:
[error] io.grpc:grpc-core:1.16.1:default(compile)
[error] io.grpc:grpc-core:1.20.0:default(compile)
[error] io.grpc:grpc-core:[1.16.1]:default(compile)
[error] io.grpc:grpc-core:[1.20.0]:default(compile)
[error] 	at lmcoursier.internal.shaded.coursier.Resolve$.validate(Resolve.scala:394)
[error] 	at lmcoursier.internal.shaded.coursier.Resolve.validate0$1(Resolve.scala:140)
[error] 	at lmcoursier.internal.shaded.coursier.Resolve.$anonfun$ioWithConflicts0$4(Resolve.scala:184)
[error] 	at lmcoursier.internal.shaded.coursier.util.Task$.$anonfun$flatMap$2(Task.scala:14)
[error] 	at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
[error] 	at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
[error] 	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
[error] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] 	at java.lang.Thread.run(Thread.java:748)
[error] (hello-impl / update) lmcoursier.internal.shaded.coursier.error.ResolutionError$ConflictingDependencies: Conflicting dependencies:
[error] io.grpc:grpc-core:1.16.1:default(compile)
[error] io.grpc:grpc-core:1.20.0:default(compile)
[error] io.grpc:grpc-core:[1.16.1]:default(compile)
[error] io.grpc:grpc-core:[1.20.0]:default(compile)

expectation

Smoother transition.

Is there a way to configure the conflict resolution rules so that it automatically uses the latest? For example in the case of the above, use io.grpc:grpc-core:1.20.0?

@eed3si9n eed3si9n referenced this issue Jul 22, 2019
3 of 6 tasks complete
@alexarchambault

This comment has been minimized.

Copy link
Member

commented Jul 23, 2019

Support for that could definitely be added, but it's not there yet. (Should require some tweaking around this method.)

About enabling it from sbt, maybe conflictManager (or a rework of it) could do? I recently added support for a strict conflict manager in coursier, not yet wired in the coursier support in sbt AFAIK.

It would be nice to be able to setup both a default conflict manager (like conflictManager allows), and a per module conflict manager, so that users can choose the strict one for some modules, and the "ignore conflicts" one (the one you propose to add above) for others, if they feel like it.

@eed3si9n

This comment has been minimized.

Copy link
Contributor Author

commented Jul 25, 2019

How do I write a failing test case for this?

    'latestWins - {
      * - async {

        val params = ResolutionParams()
          .withScalaVersion("2.12.8")
          // .addRule(
          //   something
          //   RuleResolution.TryResolve
          // )

        val res = await {
          Resolve()
            .noMirrors
            .addDependencies(
              dep"org.typelevel:cats-effect_2.12:1.3.1",
              dep"org.typelevel:cats-core_2.12:1.5.0"
            )
            .addRepositories(Repositories.central)
            .withResolutionParams(params)
            .withCache(cache)
            .future()
        }

        await(validateDependencies(res, params))
      }
    }

This gets me

X coursier.ResolveRulesTests.latestWins.0 339ms
  coursier.error.ResolutionError$CantDownloadModule: Error downloading org.typelevel:cats-effect_2.12:1.3.1
    Not found: /Users/eed3si9n/.ivy2/local/org.typelevel/cats-effect_2.12/1.3.1/ivys/ivy.xml (No such file or directory)
    not found: modules/tests/metadata/https/repo1.maven.org/maven2/org/typelevel/cats-effect_2.12/1.3.1/cats-effect_2.12-1.3.1.pom

Update:

I got the failing conflict as follows:

        val res = await {
          Resolve()
            .addDependencies(
              dep"org.webjars.npm:randomatic:1.1.7",
              dep"org.webjars.npm:is-odd:2.0.0"
            )
            .withResolutionParams(params)
            .future()
        }
X coursier.ResolveRulesTests.latestWins.0 861ms
  coursier.error.ResolutionError$ConflictingDependencies: Conflicting dependencies:
  org.webjars.npm:is-number:[3.0.0,4):default(compile)
  org.webjars.npm:is-number:[4.0.0,5):default(compile)
    coursier.Resolve$.validate(Resolve.scala:396)
    coursier.Resolve.validate0$1(Resolve.scala:141)
    coursier.Resolve.$anonfun$ioWithConflicts0$4(Resolve.scala:185)
    coursier.util.Task$.$anonfun$flatMap$2(Task.scala:14)
    scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
    scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
    scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    java.lang.Thread.run(Thread.java:748)

eed3si9n added a commit to eed3si9n/coursier that referenced this issue Jul 26, 2019

Latest-wins conflict resolution rules
Fixes coursier#1284

This implements latest-wins resolution rules, similar to that of default Ivy behavior.
@eed3si9n

This comment has been minimized.

Copy link
Contributor Author

commented Jul 26, 2019

Here's my PR #1293

eed3si9n added a commit to eed3si9n/coursier that referenced this issue Jul 31, 2019

Implement Reconciliation.Relaxed
Fixes coursier#1284

This implements an alternative reconciliation rule that first tries the basic reconciliation, and if it fails falls back to using the max values of the specific versions and lower bounds of the intervals.

eed3si9n added a commit to eed3si9n/coursier that referenced this issue Aug 1, 2019

Implement Reconciliation.Relaxed
Fixes coursier#1284

This implements an alternative reconciliation rule that first tries the basic reconciliation, and if it fails falls back to using the max values of the specific versions and lower bounds of the intervals.

alexarchambault added a commit that referenced this issue Aug 2, 2019

Reconciliation API (#1293)
* Refactor mergeVersions to Reconciliation API

To allow customization of the reconciliation of version conflicts, split `mergeVersions` out into its own API called Reconciliation.

* Implement Reconciliation.Relaxed

Fixes #1284

This implements an alternative reconciliation rule that first tries the basic reconciliation, and if it fails falls back to using the max values of the specific versions and lower bounds of the intervals.

eed3si9n added a commit to eed3si9n/coursier that referenced this issue Aug 8, 2019

Use Relaxed reconciliation by default
Fixes coursier#1312
Ref coursier#1293 / coursier#1284

This switches the default reconciliation to use the relaxed one that picks the latest version interval given multiple non-mergable ones.

eed3si9n added a commit to eed3si9n/coursier that referenced this issue Aug 8, 2019

Use Relaxed reconciliation by default
Fixes coursier#1312
Ref coursier#1293 / coursier#1284

This switches the default reconciliation to use the relaxed one that picks the latest version interval given multiple non-mergable ones.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.