question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dealing with version clashes on transitive dependencies

See original GitHub issue

I work on a Monorepo that contains several Java, Scala and Kotlin projects, all within a single WORKSPACE. Using bazel-deps worked well for a while, but as the repository grew, it has become hard to deal with transitive dependencies version clashes.

To address that, I attempted to use a dependencies.yml for each project, but it didn’t work out – the order in which we imported each project/repository on the WORKSPACE was considered when resolving conflicts. Did I do something wrong, or is it working as intended?

Is it possible to have several versions of a single dependency on the dependencies.yml file, and force which version we want for each Bazel target? It looks like rules_jvm_external supports this.

Creating WORKSPACE files for each project is looking like the way to go, but we wanted to avoid that as much as possible.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ianoc-stripecommented, Mar 24, 2020

Once you have gotten into the state its pretty hard to get out of. Our main internal control in the area’s I care about is that we heavily restrict the PR’s that can touch the workspace.bzl file, and i basically read the conflicts when it changes to decide if it seems ok or not. Having a version conflict of failed is probably pretty good for most things, some stuff like finagle, or guava can be a bit of a wild card even in this.

I would probably try the fail/fixed first to see how you can manage it, but overall i think using that or not this is going to boil down to probably visually deciding about transitive deps stability/bumping things + requesting new publishes or dropping the use of external libraries that aren’t updated/need older versions of things. Its all pretty hassle filled in any big monorepo i’ve worked on, having the reviews or settings can mostly stop it getting into the repo, but the more correct you are in what goes into your repo can mean the more effort is required to do an upgrade (which is the only stable way to do the upgrade tbc, but its time consuming, e.g: Upgrade Lib A depends on newer C which then means you need to bump B, which has a knock on effect on libraries E,F,G… etc… It does really pay to have a shallow dependency tree and I would shade something like spark where you can to use that to slim down the dependencies there)

0reactions
pbsfcommented, Mar 24, 2020

Thanks for the input. The runtime issues you guys mentioned are the ones we are dealing with atm.

We already use bazel_jar_jar on a few cases. Might be the way to go indeed. The bigger problem is that our dependencies.yml has 80 conflicting dependencies, with versionConflictPolicy=highest. It is now too hard to fix these on a case-by-case basis. Most of these conflicts are not causing runtime errors.

We are thinking about creating a new dependencies.yml file with versionConflictPolicy=fail/fixed, load it earlier than the legacy one on the WORKSPACE, and fix the conflicts as it arises on the new file. Does that seem like a reasonable migration approach? Would you recommend fail or fixed as the conflict policy?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Resolve a Version Collision of Artifacts in Maven
Excluding a Transitive Dependency From an Artifact​​ One way to resolve a version collision is by removing a conflicting transitive dependency ...
Read more >
Find and Fix Transitive Dependency Version Upgrade ...
Find and Fix Transitive Dependency Version Upgrade/Conflicts in Maven · Step 1) Find the parent dependency which brings about the vulnerability · Step...
Read more >
Solving Dependency Conflicts in Maven - DZone
Maven dependency conflicts can be really hard to solve. ... Such dependencies are better known as transitive dependencies.
Read more >
java - Are conflicting transitive dependencies a serious issue ...
Yes, such conflicts can be serious. You don't know if there is an incompatible change in a dependency when comparing versions one with ......
Read more >
Better management of transitive dependencies and conflicts
You've run into trouble with version conflicts between dependencies and didn't know what to do or where to look for advice.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found