VirtusLab / scala-cli

Scala CLI is a command-line tool to interact with the Scala language. It lets you compile, run, test, and package your Scala code (and more!)
https://scala-cli.virtuslab.org
Apache License 2.0
546 stars 127 forks source link

Possible change in dependency publication method #3088

Closed TonioGela closed 1 month ago

TonioGela commented 2 months ago

Version(s) 1.4.1+

Describe the bug Very much like it happened for #2809 (hence the name of the this bug) something in the publication strategy of org.virtuslab.scala-cli::cli might have changed since version 1.4.1 as in the compilation of the tests packages of the typelevel toolkit (for all versions and platforms) we're experiencing the following exception:

[error] Modules were resolved with conflicting cross-version suffixes in ProjectRef(uri("file:/home/runner/work/toolkit/toolkit/"), "testsJS"):
[error]    org.scala-lang.modules:scala-collection-compat _3, _2.13
[error]    com.lihaoyi:sourcecode _3, _2.13
[error] Modules were resolved with conflicting cross-version suffixes in ProjectRef(uri("file:/home/runner/work/toolkit/toolkit/"), "testsJVM"):
[error]    org.scala-lang.modules:scala-collection-compat _3, _2.13
[error]    com.lihaoyi:sourcecode _3, _2.13
[error] Modules were resolved with conflicting cross-version suffixes in ProjectRef(uri("file:/home/runner/work/toolkit/toolkit/"), "testsNative"):
[error]    org.scala-lang.modules:scala-collection-compat _3, _2.13
[error]    com.lihaoyi:sourcecode _3, _2.13
[error] java.lang.RuntimeException: Conflicting cross-version suffixes in: org.scala-lang.modules:scala-collection-compat, com.lihaoyi:sourcecode

and we haven't really changed anything on our side.

Keeping in mind what @Gedochao once said those are internal APIs, not necessarily prepared for external use (so there's no guarantees on our side, really) I still felt like raising a bug, because this might be simply highlighting something more serious.

To Reproduce Declaring org.virtuslab.scala-cli::cli as a dependency in any 2.13 or 3 project won't make the tool able to correctly solve the dependency.

Thanks in advance for any help or info that you might provide.

tgodzik commented 1 month ago

Thanks for reporting, looks like this might be caused by trees dependency from scalameta:

I am not sure how that changes especially that we used to shade it. A workaround for now would be just excluding sourcecode_2.13 either here or in typelevel toolkit.

I will take a look what happened on the scalameta side. There was a bit of reshuffling of modules

TonioGela commented 1 month ago

Thanks for solving this! Is there maybe a snapshot I can use to test tl-toolkit CI?

tgodzik commented 1 month ago

There will be a nightly to test out, but I think our CI is quite full at the moment

tgodzik commented 1 month ago

You can test out 1.4.3-9-g57d633514-SNAPSHOT/

I don't see the 2.13 sourcecode dependency anymore

tgodzik commented 1 month ago

Although, I might need to exclude scala-collection-compat also :thinking:

TonioGela commented 1 month ago

It seems that shading didn't solve the original issue though: https://github.com/typelevel/toolkit/actions/runs/10400127288/job/28800129401

tgodzik commented 1 month ago

Wait, but where is com.lihaoyi:sourcecode_2.13 coming from?

TonioGela commented 1 month ago

Wait, but where is com.lihaoyi:sourcecode_2.13 coming from?

I'm trying to figure it out, once I'll find it out I'll tell you :)

tgodzik commented 1 month ago

Maybe, we still haven't published the fixed version :thinking:

TonioGela commented 1 month ago

Maybe, we still haven't published the fixed version 🤔

Might be, I think this was the CI run pointing at this branch getting into main: https://github.com/VirtusLab/scala-cli/actions/runs/10387953976

tgodzik commented 1 month ago

As an alternative, you can do:

      "com.lihaoyi" %% "sourcecode" % "0.4.3" % Test,
      "org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0" % Test,
      ("org.virtuslab.scala-cli" %% "cli" % "1.4.3" cross (CrossVersion.for2_13Use3))
        .exclude("com.lihaoyi", "sourcecode_2.13")
        .exclude("org.scala-lang.modules", "scala-collection-compat_2.13")

uncomment the deps added if it turns out it break otherwise this should work

tgodzik commented 1 month ago

And in the meantime https://github.com/VirtusLab/scala-cli/pull/3105 should work.

I forgot that we need exact name of the artifact with _2.13

TonioGela commented 1 month ago

As an alternative, you can do:

      "com.lihaoyi" %% "sourcecode" % "0.4.3" % Test,
      "org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0" % Test,
      ("org.virtuslab.scala-cli" %% "cli" % "1.4.3" cross (CrossVersion.for2_13Use3))
        .exclude("com.lihaoyi", "sourcecode_2.13")
        .exclude("org.scala-lang.modules", "scala-collection-compat_2.13")

~uncomment the deps added if it turns out it break otherwise~ this should work

Yes, of course, thanks :D That's the way that I would have followed in case you would have closed this as a won't fix for the aforementioned reasons.

I have the general feeling that you (meaning the contributors of this project) don't completely dislike the fact that the typelevel toolkit tests are constantly probing the cli artifact, that's why I'm here 😇

tgodzik commented 1 month ago

It's always good to report things like this, we might not be able to fix them right away, but it's good to know when something is off (and this case certainly is a bit off)