almond-sh / almond

A Scala kernel for Jupyter
https://almond.sh
BSD 3-Clause "New" or "Revised" License
1.6k stars 238 forks source link

Jupyter kernel fails to run in standalone mode with Scala 3 #1422

Open Snowflyt opened 1 month ago

Snowflyt commented 1 month ago

Description

After installing Almond Jupyter kernel in standalone mode (coursier bootstrap almond:0.14.0-RC15 --standalone -o almond && ./almond --install) with Scala 3, it fails to run properly. The kernel starts successfully, but when attempting to run any code, it reports the following error:

java.lang.NullPointerException: Cannot invoke "dotty.tools.io.AbstractFile.file()" because "zipFile" is null
  dotty.tools.dotc.classpath.ZipAndJarFileLookupFactory.create(ZipAndJarFileLookupFactory.scala:29)
  dotty.tools.dotc.classpath.ZipAndJarFileLookupFactory.create$(ZipAndJarFileLookupFactory.scala:24)
  dotty.tools.dotc.classpath.ZipAndJarClassPathFactory$.create(ZipAndJarFileLookupFactory.scala:42)
  ammonite.compiler.Compiler.$anonfun$5(Compiler.scala:123)
  scala.collection.immutable.Vector2.map(Vector.scala:2140)
  scala.collection.immutable.Vector2.map(Vector.scala:443)
  ammonite.compiler.Compiler.ammonite$compiler$Compiler$$asDottyClassPath(Compiler.scala:123)
  ammonite.compiler.Compiler$$anon$3.classPath(Compiler.scala:75)
  dotty.tools.dotc.config.JavaPlatform.rootLoader(JavaPlatform.scala:38)
  dotty.tools.dotc.core.Contexts$ContextBase.rootLoader(Contexts.scala:879)
  dotty.tools.dotc.core.Definitions.RootClass$$anonfun$1(Definitions.scala:202)
  dotty.tools.dotc.core.Symbols$.$anonfun$2(Symbols.scala:605)
  dotty.tools.dotc.core.Symbols$.newClassSymbol(Symbols.scala:539)
  dotty.tools.dotc.core.Symbols$.newModuleSymbol(Symbols.scala:605)
  dotty.tools.dotc.core.Symbols$.newPackageSymbol(Symbols.scala:666)
  dotty.tools.dotc.core.Definitions.RootClass(Definitions.scala:202)
  dotty.tools.dotc.core.Denotations$.recurSimple$1(Denotations.scala:1334)
  dotty.tools.dotc.core.Denotations$.recur$1(Denotations.scala:1338)
  dotty.tools.dotc.core.Denotations$.staticRef(Denotations.scala:1342)
  dotty.tools.dotc.core.Symbols$.requiredPackage(Symbols.scala:891)
  dotty.tools.dotc.core.Definitions.ScalaPackageVal(Definitions.scala:214)
  dotty.tools.dotc.core.Definitions.ScalaPackageClass(Definitions.scala:217)
  dotty.tools.dotc.core.Definitions.AnyClass(Definitions.scala:277)
  dotty.tools.dotc.core.Definitions.syntheticScalaClasses(Definitions.scala:2092)
  dotty.tools.dotc.core.Definitions.syntheticCoreClasses(Definitions.scala:2106)
  dotty.tools.dotc.core.Definitions.init(Definitions.scala:2123)
  dotty.tools.dotc.core.Contexts$ContextBase.initialize(Contexts.scala:892)
  ammonite.compiler.Compiler.initialCtx$lzyINIT1(Compiler.scala:145)
  ammonite.compiler.Compiler.initialCtx(Compiler.scala:133)
  almond.amm.AlmondCompilerLifecycleManager.preprocess(AlmondCompilerLifecycleManager.scala:36)
  ammonite.interp.Interpreter.processLine$$anonfun$1$$anonfun$2(Interpreter.scala:254)
  ammonite.util.Res$Success.flatMap(Res.scala:58)
  ammonite.interp.Interpreter.processLine$$anonfun$1(Interpreter.scala:274)
  ammonite.util.Catching.flatMap(Res.scala:110)
  ammonite.interp.Interpreter.processLine(Interpreter.scala:274)
  almond.Execute.ammResult$$anonfun$1$$anonfun$2$$anonfun$1$$anonfun$1$$anonfun$1$$anonfun$1(Execute.scala:360)
  almond.internals.CaptureImpl.apply$$anonfun$1$$anonfun$1(CaptureImpl.scala:64)
  scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
  scala.Console$.withErr(Console.scala:193)
  almond.internals.CaptureImpl.apply$$anonfun$1(CaptureImpl.scala:70)
  scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
  scala.Console$.withOut(Console.scala:164)
  almond.internals.CaptureImpl.apply(CaptureImpl.scala:71)
  almond.Execute.capturingOutput(Execute.scala:246)
  almond.Execute.ammResult$$anonfun$1$$anonfun$2$$anonfun$1$$anonfun$1$$anonfun$1(Execute.scala:412)
  almond.Execute.withClientStdin$$anonfun$1(Execute.scala:225)
  scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
  scala.Console$.withIn(Console.scala:227)
  almond.Execute.withClientStdin(Execute.scala:231)
  almond.Execute.ammResult$$anonfun$1$$anonfun$2$$anonfun$1$$anonfun$1(Execute.scala:413)
  almond.Execute.withInputManager(Execute.scala:211)
  almond.Execute.ammResult$$anonfun$1$$anonfun$2$$anonfun$1(Execute.scala:414)
  almond.Execute.interruptible$$anonfun$2(Execute.scala:275)
  ammonite.repl.Signaller.apply(Signaller.scala:28)
  almond.Execute.interruptible(Execute.scala:276)
  almond.Execute.ammResult$$anonfun$1$$anonfun$2(Execute.scala:415)
  ammonite.util.Res$Success.flatMap(Res.scala:58)
  almond.Execute.ammResult$$anonfun$1(Execute.scala:416)
  almond.Execute.withOutputHandler(Execute.scala:237)
  almond.Execute.ammResult(Execute.scala:417)
  almond.Execute.apply(Execute.scala:535)
  almond.ScalaInterpreter.execute(ScalaInterpreter.scala:182)
  almond.interpreter.InterpreterToIOInterpreter.execute$$anonfun$1$$anonfun$1(InterpreterToIOInterpreter.scala:66)
  cats.effect.IOFiber.runLoop(IOFiber.scala:264)
  cats.effect.IOFiber.autoCedeR(IOFiber.scala:1423)
  cats.effect.IOFiber.run(IOFiber.scala:119)
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
  java.lang.Thread.run(Thread.java:1583)

I have tried installing using coursier launch --use-bootstrap with Scala 3 and coursier bootstrap almond:0.14.0-RC15 --scala 2.13.14, and both methods worked without any issues. The problem only occurs when installing using standalone mode with Scala 3.

Steps to Reproduce

  1. Install coursier and latest Scala.

    curl -fL https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz | gzip -d > cs
    chmod +x cs
    ./cs setup
    export PATH="$HOME/.local/share/coursier/bin:$PATH"
  2. Install Almond Jupyter kernel in standalone mode.

    cs bootstrap almond:0.14.0-RC15 --standalone -o almond
    ./almond --install
  3. Start JupyterLab (Also tried in VS Code).

    jupyter lab

Environment

Jupyter version:

IPython          : 8.26.0
ipykernel        : 6.29.5
ipywidgets       : not installed
jupyter_client   : 8.6.2
jupyter_core     : 5.7.2
jupyter_server   : 2.14.2
jupyterlab       : 4.2.5
nbclient         : 0.10.0
nbconvert        : 7.16.4
nbformat         : 5.10.4
notebook         : not installed
qtconsole        : not installed
traitlets        : 5.14.3