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.

sbt resolves dependencies differently with/without coursier

See original GitHub issue

Hi,

Since sbt switched to Coursier I’ve faced with the issue described in https://github.com/sbt/sbt/issues/5389. It looks like the root cause of the issue is a different classpath we get using Ivy and Coursier.

So, here is a problem repo https://github.com/rusexpertiza-llc/yupana. The subproject is hbase. Here is the diff between Ivy dependencies and Coursier:

- guava-12.0.1.jar
+ guava-16.0.1.jar
+ hadoop-mapreduce-client-core-2.5.1.jar
+ hadoop-yarn-api-2.5.1.jar
+ hadoop-yarn-common-2.5.1.jar
+ jline-0.9.94.jar
+ netty-3.7.0.Final.jar
- protobuf-java-2.6.1.jar
+ protobuf-java-3.8.0.jar
+servlet-api-2.5-20081211.jar

One of the problems I see here is that forced version for protobuf-java is ignored.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
eed3si9ncommented, Mar 17, 2021

It’s interesting that the dependency resolution differences seem to be around Hadoop related things. For example, if you look at cs resolve org.apache.hadoop:hadoop-common:2.9.2 -t, you’d see the libraries that are mentioned here like netty-3.7.0.Final and nimbus-jose-jw.

It would be good to compare not just Ivy vs Coursier, but also the resolution result of Maven as well because some of the differences could be coming from the fact that Coursier is doing a better job emulating Maven, especially when it comes to traversing the parent POMs.

Hadoop depends on Apache Curator Framework. https://repo1.maven.org/maven2/org/apache/curator/curator-framework/2.7.1/curator-framework-2.7.1.pom At a glance it doesn’t look like it doesn’t depend on much:

<dependencies>
  <dependency>
    <groupId>org.apache.curator</groupId>
    <artifactId>curator-client</artifactId>
  </dependency>
  <dependency>
    <groupId>org.apache.curator</groupId>
    <artifactId>curator-test</artifactId>
    <scope>test</scope>
  </dependency>
</dependencies>

but wait there’s more…

<parent>
  <groupId>org.apache.curator</groupId>
  <artifactId>apache-curator</artifactId>
  <version>2.7.1</version>
</parent>

Here’s the parent POM - https://repo1.maven.org/maven2/org/apache/curator/apache-curator/2.7.1/apache-curator-2.7.1.pom

<dependencies>
  <dependency>
    <groupId>org.apache.zookeeper</groupId>
    <artifactId>zookeeper</artifactId>
  </dependency>
  <dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
  </dependency>
  <dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <scope>test</scope>
  </dependency>
</dependencies>

That’s Guava 16 and Zookeeper 3.4.6. Hadoop also depends on Zookeeper but with excludes. Curator doesn’t have those excludes.

What does Zookeeper 3.4.6 depend on? https://repo1.maven.org/maven2/org/apache/zookeeper/zookeeper/3.4.6/zookeeper-3.4.6.pom

<dependency>
  <groupId>jline</groupId>
  <artifactId>jline</artifactId>
  <version>0.9.94</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty</artifactId>
  <version>3.7.0.Final</version>
  <scope>compile</scope>
</dependency>

That’s right JLine 0.9.94 and Netty 3.7.0.Final.

I mean you probably don’t need those (and that’s why Hadoop excludes them), but when I see extra JLine or Netty, I usually assume that Coursier is being correct.

1reaction
bpossolocommented, Feb 10, 2021

upgraded from sbt 1.3.4 to 1.4.7 (required because im on a new M1 MacBook Air)… I’ve noticed major differences between the coursier and ivy classpaths as well…

for example my project depends on com.microsoft.azure:msal4j:1.8.0 that lib depends on com.nimbusds:oauth2-oidc-sdk:7.4 which depends on com.nimbusds:nimbus-jose-jwt:8.14.1

coursier doesn’t even download either of those two jars nor add them to the classpath…

I had to disable coursier to get my project to function. ThisBuild / useCoursier := false

seems odd to rewrite dependency management when maven/ivy are tried and trued…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Version handling - Coursier
Version reconciliation happens when two or more of your direct or transitive dependencies depend on different versions of the same module.
Read more >
Better management of transitive dependencies and conflicts
By default, both Ivy and coursier tolerate that the dependency graph contains two different versions of a library, in which case they pick...
Read more >
SBT with 1.3.7 coursier fails to resolve dependency ... - GitHub
I confirm that sbt-google-cloud-storage can't work out-of-the-box with coursier. It relies on a custom resolver class, which is not supported by ...
Read more >
sbt Reference Manual — Library Management
sbt 1.3.0+ uses Coursier to implement dependency management. ... what to do when dependency resolution brings in different versions of the same library....
Read more >
semantics of dependency resolvers - eed3si9n
A dependency resolver, or package manager, is a program that ... out, Coursier orders version number in a completely different way from Ivy....
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