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

doesn't work with scala 3 + scala-native #4114

Closed
scarf005 opened this issue Aug 11, 2024 · 6 comments
Closed

doesn't work with scala 3 + scala-native #4114

scarf005 opened this issue Aug 11, 2024 · 6 comments

Comments

@scarf005
Copy link

scarf005 commented Aug 11, 2024

tutorial referenced: https://typelevel.org/cats-effect/docs/core/scala-native

//> using dep "org.typelevel::cats-effect:3.5.4"
import cats.effect.{IO, IOApp}

object Main extends IOApp.Simple {
  def run: IO[Unit] = IO.println("Hello Cats Effect!")
}
$ time scala-cli --power package --native --native-mode release-full 2015/Test.scala
Compiling project (Scala 3.4.2, Scala Native 0.5.4)
Compiled project (Scala 3.4.2, Scala Native 0.5.4)
Picked up _JAVA_OPTIONS: -Djava.util.prefs.userRoot=/home/scarf/.config/java
[info] Linking (multithreadingEnabled=true, disable if not used) (1311 ms)
[info] Discovered 863 classes and 5277 methods after classloading
[error] Found 4 unreachable symbols!
[error] Unknown method cats.effect.IOApp.main(java.lang.String[]): scala.runtime.BoxedUnit, referenced from:
         method Main$.main(java.lang.String[]): scala.runtime.BoxedUnit at Test.scala:5
  static method Main.main(java.lang.String[]): scala.runtime.BoxedUnit at Test.scala:5


[error] Unknown method cats.effect.IOApp.$init$(): scala.runtime.BoxedUnit, referenced from:
    constructor Main$() at Test.scala:5
  static method Main.main(java.lang.String[]): scala.runtime.BoxedUnit at Test.scala:5


[error] Unknown type cats.effect.IOApp, referenced from:
         method Main$.main(java.lang.String[]): scala.runtime.BoxedUnit at Test.scala:5
  static method Main.main(java.lang.String[]): scala.runtime.BoxedUnit at Test.scala:5


[error] Unknown type cats.effect.IOApp$Simple, referenced from:
           type Main$ at Test.scala:5
  static method Main.main(java.lang.String[]): scala.runtime.BoxedUnit at Test.scala:5


[info] Total (1456 ms)
Exception in thread "main" scala.scalanative.linker.LinkingException: Unreachable symbols found after classloading run. It can happen when using dependencies not cross-compiled for Scala Native or not yet ported JDK definitions.
        at scala.scalanative.build.ScalaNative$.$anonfun$withReachabilityPostprocessing$3(ScalaNative.scala:94)
        at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
        at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:51)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:74)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Error: scala.build.errors.ScalaNativeBuildError: Error compiling with Scala Native
For more details, please see '/home/scarf/repo/aoc-scala/2015/.scala-build/stacktraces/1723357516-2436857827086343636.log'

________________________________________________________
Executed in    2.66 secs    fish           external
   usr time    6.05 secs    0.00 millis    6.05 secs
   sys time    0.80 secs    1.24 millis    0.79 secs

System info

OS: ubuntu 22.04
scala-cli: 1.4.3
Scala version (default): 3.4.2
@lenguyenthanh
Copy link
Member

CE only supports scala native 0.4.x for now. They have plan for it, but it'll take a while. You can see more context here: #4076

@scarf005
Copy link
Author

thanks, but it still doesn't seem to work in 0.4.x:

//> using nativeVersion 0.4.17  
//> using scala 3.4.2
//> using dep "org.typelevel::cats-effect:3.5.4"
import cats.effect.{IO, IOApp}

object Main extends IOApp.Simple {
  def run: IO[Unit] = IO.println("Hello Cats Effect!")
}
time scala-cli --power package --native --native-mode release-full 2015/Test.scala
Picked up _JAVA_OPTIONS: -Djava.util.prefs.userRoot=/home/scarf/.config/java
[error] Found 4 missing definitions while linking
[error] Not found Top(cats.effect.IOApp)
[error]         at file:/home/scarf/repo/aoc-scala/2015/Test.scala:6
[error] Not found Member(Top(cats.effect.IOApp),D4mainLAL16java.lang.String_uEO)
[error]         at file:/home/scarf/repo/aoc-scala/2015/Test.scala:6
[error] Not found Member(Top(cats.effect.IOApp),D6$init$uEO)
[error]         at file:/home/scarf/repo/aoc-scala/2015/Test.scala:6
[error] Not found Top(cats.effect.IOApp$Simple)
Exception in thread "main" scala.scalanative.linker.LinkingException: Undefined definitions found in reachability phase
        at scala.scalanative.linker.Reach.fail(Reach.scala:979)
        at scala.scalanative.linker.Reach.reportMissing(Reach.scala:974)
        at scala.scalanative.linker.Reach.result(Reach.scala:52)
        at scala.scalanative.linker.Reach$.apply(Reach.scala:992)
        at scala.scalanative.linker.Link$.apply(Link.scala:13)
        at scala.scalanative.build.core.ScalaNative$.$anonfun$link$1(ScalaNative.scala:34)
        at scala.scalanative.build.Logger.time(Logger.scala:35)
        at scala.scalanative.build.Logger.time$(Logger.scala:32)
        at scala.scalanative.cli.utils.FilteredLogger.time(FilteredLogger.scala:7)
        at scala.scalanative.build.core.ScalaNative$.link(ScalaNative.scala:34)
        at scala.scalanative.build.Build$.$anonfun$build$1(Build.scala:73)
        at scala.scalanative.build.Logger.time(Logger.scala:35)
        at scala.scalanative.build.Logger.time$(Logger.scala:32)
        at scala.scalanative.cli.utils.FilteredLogger.time(FilteredLogger.scala:7)
        at scala.scalanative.build.Build$.build(Build.scala:61)
        at scala.scalanative.cli.ScalaNativeLd$.$anonfun$runLd$3(ScalaNativeLd.scala:73)
        at scala.scalanative.util.Scope$.apply(Scope.scala:32)
        at scala.scalanative.cli.ScalaNativeLd$.runLd(ScalaNativeLd.scala:72)
        at scala.scalanative.cli.ScalaNativeLd$.main(ScalaNativeLd.scala:42)
        at scala.scalanative.cli.ScalaNativeLd.main(ScalaNativeLd.scala)
Error: scala.build.errors.ScalaNativeBuildError: Error compiling with Scala Native
For more details, please see '/home/scarf/repo/aoc-scala/2015/.scala-build/stacktraces/1723359533-11119898221186217259.log'

1723359533-11119898221186217259.log

@armanbilge
Copy link
Member

@scarf005 you are missing a colon.

https://youforgotapercentagesignoracolon.com/

@scarf005
Copy link
Author

scarf005 commented Aug 11, 2024

@scarf005 you are missing a colon.

https://youforgotapercentagesignoracolon.com/

thanks. but shouldn't this be documented in scala-cli docs page?

EDIT: adding colon still doesn't seem to work.

 scala-cli run  --native --native-mode release-full . --main-class day7.main
Downloading 10 dependencies
[error] ./project.scala:10:16
[error] Error downloading org.typelevel:cats-effect_native0.5_3:3.5.4
[error]   not found: /home/scarf/.cache/scalacli/local-repo/1.4.3/org.typelevel/cats-effect_native0.5_3/3.5.4/ivys/ivy.xml
[error]   No fallback URL found
[error]   not found: /home/scarf/.ivy2/local/org.typelevel/cats-effect_native0.5_3/3.5.4/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/org/typelevel/cats-effect_native0.5_3/3.5.4/cats-effect_native0.5_3-3.5.4.pom
[error] //> using dep "org.typelevel::cats-effect::3.5.4"
[error]                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@lenguyenthanh
Copy link
Member

lenguyenthanh commented Aug 12, 2024

[error] Error downloading org.typelevel:cats-effect_native0.5_3:3.5.4
[error] not found: /home/scarf/.cache/scalacli/local-repo/1.4.3/org.typelevel/cats-effect_native0.5_3/3.5.4/ivys/ivy.xml

You now use native 0.5.3 again :p

@durban
Copy link
Contributor

durban commented Sep 1, 2024

If I understand it correctly, every behavior have been explained, so I'm closing this. Feel free to reopen if there are still issues.

@durban durban closed this as completed Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants