Coursier resolution of Scala 3 dependencies

What am I doing wrong here?

cs resolve com.sageserpent::americium:1.16.1|grep americium
com.sageserpent:americium_2.13:1.16.1:default

So far so good - Americium is cross built for Scala 2.13 and 3.

Let’s check the Scala 3 dependencies…

cs resolve com.sageserpent::americium:1.16.1 --scala-version=3|grep americium
com.sageserpent:americium_2.13:1.16.1:default

That doesn’t seem right - there are Scala 3 artifacts over at Maven Central. Can I jemmy this…?

cs resolve com.sageserpent::americium:1.16.1 --scala-version=3 --force-scala-version=true|grep americium
com.sageserpent:americium_2.13:1.16.1:default

Nope. What if I just add the _3 suffix into the artifact itself and lose a colon…?

cs resolve com.sageserpent:americium_3:1.16.1 |grep americium
com.sageserpent:americium_3:1.16.1:default

Well that one worked!

So I do have a workaround, but I’m a bit perturbed as to why Coursier doesn’t pick up the Scala 3 artifacts.

I saw this: cs does not install scala runner for scala 3 · Issue #2058 · coursier/coursier · GitHub, but that has been closed, and I’m not sure it’s directly relevant.

Any pointers? Should I just stick with the explicit _3 as if I was writing a Maven dependency?

1 Like

I think you have to give it a full scala version.

❯ cs resolve com.typesafe.slick::slick:3.5.0-RC1 --scala-version=3.3.0
com.typesafe:config:1.4.3:default
com.typesafe.slick:slick_3:3.5.0-RC1:default
org.reactivestreams:reactive-streams:1.0.4:default
org.scala-lang:scala-library:2.13.10:default
org.scala-lang:scala3-library_3:3.3.1:default
org.slf4j:slf4j-api:2.0.12:default

❯ cs resolve com.typesafe.slick::slick:3.5.0-RC1 --scala-version=3
Can't find a scala version suffix for com.typesafe.slick::slick:3.5.0-RC1 (likely a non existing module or version)
❯ cs resolve com.sageserpent::americium:1.16.1 --scala-version=3.3.0 | grep  amer
com.sageserpent:americium_3:1.16.1:default

I don’t know why for americium it falls back to scala 2 vs. printing the error I got with Slick.

Thanks for taking a look, @nafg.

The plot thickens…

I had tried just a --scala-version=3.1 (3.2, 3.3), but that yields a Can't find a scala version suffix error, which seemed reasonable to me as my impression is that since Scala 3, the major versions increments are all considered equivalent regarding artifacts.

So whereas 2.11, 2.12 and 2.13 have their own artifact suffices of _2.11 etc, 3.0, 3.1, 3.2 and 3.3 are all just _3.

I could be wrong there, if anyone knows otherwise please speak up.

I tried your suggestion, but what I see is this:

% cs resolve --scala-version=3.3.0 com.sageserpent::americium:1.16.1
Resolution error: Error downloading com.sageserpent:americium_3.3:1.16.1
https://repo1.maven.org/maven2/com/sageserpent/americium_3.3/1.16.1/americium_3.3-1.16.1.pom

% cs resolve com.sageserpent::americium:1.16.1 --scala-version=3.3.0 
Resolution error: Error downloading com.sageserpent:americium_3.3:1.16.1
  not found: https://repo1.maven.org/maven2/com/sageserpent/americium_3.3/1.16.1/americium_3.3-1.16.1.pom

% cs resolve com.typesafe.slick::slick:3.5.0-RC1 --scala-version=3.3.0
  not found: https://repo1.maven.org/maven2/com/typesafe/slick/slick_3.3/3.5.0-RC1/slick_3.3-3.5.0-RC1.pom

% cs --version
2.0.16

% cs resolve com.typesafe.slick::slick:3.5.0-RC1 --scala-version=3.3  
Can't find a scala version suffix for com.typesafe.slick::slick:3.5.0-RC1 (likely a non existing module or version)

What version of Coursier are you using? The one I’m using seems to be going for _3.3 as the artifact suffix, contrary to what I thought.

Also, I wonder whether Slick has an application descriptor for it? - I haven’t done this for Americium, which might explain the fallback to the 2.13 artifacts.

Checked that:

% cs resolve com.typesafe.slick::slick:3.5.0-RC1 --scala-version=3    
com.typesafe:config:1.4.3:default
com.typesafe.slick:slick_2.13:3.5.0-RC1:default
org.reactivestreams:reactive-streams:1.0.4:default
org.scala-lang:scala-library:2.13.12:default
org.slf4j:slf4j-api:2.0.12:default

This also falls back to 2.13 with the version of Coursier I’m using (2.0.16).

Hmm - I found this: Resolve dependencies with a Scala 3 partial version (#2606) · coursier/coursier@e5276c3 · GitHub and noticed the version is in range v2.1.9 … v2.1.0-RC3-1, which is beyond 2.0.16.

I had tried upgrading Coursier via cs update, but saw this…

cs update
https://repo1.maven.org/maven2/io/get-coursier/coursier-cli_2.13/maven-metadata.xml
  No new update since 2023-11-22 14:16:31
Error downloading gz+https://github.com/coursier/coursier/releases/download/v2.1.8/cs-x86_64-apple-darwin.gz

So I suspect a reinstallation should sort this out.

Reinstallation sorted that out by unblocking the upgrade.

cs version // 2.1.8

cs resolve com.typesafe.slick::slick:3.5.0-RC1 --scala-version=3.1|fgrep slick // com.typesafe.slick:slick_3:3.5.0-RC1:default

cs resolve com.typesafe.slick::slick:3.5.0-RC1 --scala-version=3.4|fgrep slick // Can’t find a scala version suffix for com.typesafe.slick::slick:3.5.0-RC1 (likely a non existing module or version)

cs resolve com.typesafe.slick::slick:3.5.0-RC1 --scala-version=3|fgrep slick // com.typesafe.slick:slick_3:3.5.0-RC1:default

cs resolve com.sageserpent::americium:1.16.1 --scala-version=3|grep americium // com.sageserpent:americium_3:1.16.1:default

cs resolve com.sageserpent::americium:1.16.1 --scala-version=3.3|grep americium // com.sageserpent:americium_3:1.16.1:default

Excellent, case closed!

1 Like