[2.x] fix: Fix consoleProject for Scala 3 (#9073)
Problem consoleProject does not work with Scala 3 because the compiler bridge does not implement REPL binding injection (scala/scala3#5069). The bindings currentState, extracted, and cpHelpers are never injected into the REPL session, causing Not found errors.
Solution Work around the missing binding support by storing the three runtime objects in a static holder (ConsoleProjectBindings) before launching the REPL, and generating val definitions via initialCommands that read from the holder. The original bindings are still passed to Console to preserve Scala 2 backward compatibility.
Pass -Xrepl-interrupt-instrumentation:local to the REPL when the consoleProject scala instance is 3.8 or newer. In local mode the instrumented loader skips re-defining classpath classes and falls through to standard parent-first delegation, so REPL code sees the same singleton sbt.* and scala.* classes as the surrounding sbt process — while still keeping interrupt support for REPL-defined code, preserving Ctrl+C on long-running expressions like (Compile / compile).eval.
Co-authored-by: Claude Opus 4.6 (1M context) noreply@anthropic.com
sbt
sbt is a build tool for Scala, Java, and more.
For general documentation, see https://www.scala-sbt.org/.
sbt 2.x
This is the 2.x series of sbt. The source code of sbt is split across several GitHub repositories, including this one.
sbt.iomodule.Other links
Issues and Pull Requests
Please read CONTRIBUTING carefully before opening a GitHub Issue or a pull request.
If you’re looking for an idea for a contribution, issues labeled with good first issue or help wanted might be good starting points.
If you would like to ask questions about sbt, there’s sbt channel on Scala Discord, but it would be good to gather questions on Stackoverflow.
license
See LICENSE.