-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Bumping sbt to 1.4.4 breaks repl #10558
Comments
Also sbt/sbt#6181 |
I though this would help with scala/scala3#10558 but `sbt repl` still hides the input after typing a line and pressing enter even after this change.
What is |
It's a command defined in the dotty project itself to run the repl of the compiler we're compiling instead of the one we're using to compile ourselves: https://github.com/lampepfl/dotty/blob/31751b9a12170cd972070a2f7f10447b0ae0901a/project/Build.scala#L607 |
Yeah, I figured it was something like that. Your problem is here: https://github.com/lampepfl/dotty/blob/31751b9a12170cd972070a2f7f10447b0ae0901a/project/Build.scala#L586 I'm guessing runProcess does something like inherit io. To make this work with sbt 1.4.x, you'll probably need to wire up runProcess to use Redirect.PIPE (https://docs.oracle.com/javase/8/docs/api/java/lang/ProcessBuilder.Redirect.html). At any rate, interactive forked processes are not really well supported in sbt 1.4.x so you should feel free to open an issue about that. Your other option is to rewrite the task to not fork and run in-process in a separate classloader. |
But I tried replacing every occurence of INHERIT with PIPE and it didn't make any difference. |
... but actually, runCompilerMain doesn't call runProcess, the code you pointed to is never called from the |
Yeah, I was groggy and my manual code navigation skills failed me. AFAICT, |
That was quick, thanks!
I think I like forking because it gives me peace of mind: I get a blank JVM where I have some ideas of how to debug things, whereas I'm really out of my comfort zone when I have to deal with the classloader mille-feuilles I get from sbt :). > scala3-compiler/run tests/pos/HelloWorld.scala -d temp
> scala3-compiler/run -classpath temp -decompile HelloWorld.tasty I get: java.lang.NoSuchMethodError: scala.quoted.Quotes$Reflection.PackageClauseTypeTest$(Lscala/quoted/Quotes$Reflection;)Lscala/reflect/TypeTest; while compiling HelloWorld The problem (I'm guessing) is that scala3-compiler depends on scala3-library which are both defined in the current sbt project, but scala3-compiler has to be compiled with an older scala3-compiler and thus an older scala3-library, it's a class from that older library without some newly added method that ends up being classloaded, probably because the scala instance classloader is a parent of the classloader sbt uses to run tasks. Now, I see that sbt/sbt#6185 adds an |
I get that. The reason that I'm suggesting not forking is that forking is barely tested by the sbt developers so even though it may feel better to you, it's not actually the strategy that is most likely to lead to success. Because sbt is so complex, there are only a small number of people who know it well enough to diagnose and debug certain issues. I am not going to be around forever, but there are things that I can fix in 10 minutes that could easily take days or even weeks for pretty much anyone else. But when I fix something for you, you learn something about sbt which makes you more able to help yourself and others in the future.
So maybe for now the solution is to just not fork in the repl project. My understanding is that there is a lot of scala 3 integration work planned for sbt 1.5.0 so that they are ready to launch together early next year. The classpath stuff can be worked through as part of the integration work that @adpi2 is doing. |
That is unfortunate given that forking is necessary when one needs to use
Unfortunately even if I disable forking only for the repl task, we're likely to run into the same sort of classloader issues: in the repl users can call macros, and to execute a macro the compiler classloads user-written code which can refer to library code, so if the classloader parent contains an old version of the library code things can go wrong. |
(in general, the classloader situation for macros isn't great at all, perhaps we could do better if we could coordinate more with sbt: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/util/ClasspathFromClassloader.scala) |
A possible workaround: |
After opening REPL with
sbt repl
and typing some code:This seems to happen for all sbt 1.4.x versions
The text was updated successfully, but these errors were encountered: