CLI `bloop console` no longer opens a console - just prints out the command
This used to work in bloop 1.6 and stopped working in 2.0. Old behavior:
❯ bloop console root
Loading...
Welcome to the Ammonite Repl 3.0.0-2-6342755f (Scala 2.12.20 Java 17.0.4)
@
New behavior:
❯ bloop console root
coursier
launch
com.lihaoyi:ammonite_2.12.17:latest.release
--main-class
ammonite.Main
--extra-jars
/Users/alec/Scratch/metals-testing/base-package/.bloop/root/bloop-bsp-clients-classes/classes-bloop-cli-_oaozKDLTuOj2J4t5d38hw==
--extra-jars
/Users/alec/Scratch/metals-testing/base-package/.bloop/root/scala-2.12/classes
--extra-jars
/Users/alec/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.17/scala-library-2.12.17.jar
--
Looks like this stopped working when Bloopgun.scala got deleted - that used to intercept some calls to console and add in the --out-file and then actually execute that.
https://github.com/scalacenter/bloop/blob/6a32d20e9ad66f61d823a2080ae71b0363410837/bloopgun/src/main/scala/bloop/bloopgun/Bloopgun.scala#L240-L241
Based on the old code as well as the behavior with the --repl scalac flag, it sounds like the bug here is that in Interpreter.scala we aren't actually running the REPL anymore. IIUC, we probably shouldn't be printing out the courier command at all.
If someone can confirm the above, I'd be happy to fix this.
Thanks for reporting! I haven't focused on the CLI enough, it would be awesome if you could take a look, otherwise I will work on it later on.
It seems that you are right and we've been intercepting the calls to console. I thought there were some tests for that, but I must have missed this somehow.
@tgodzik I think I have a fix, but I'm running into the blocker that I can't find any way to install bloop locally. Are the contributing instructions (specifically the section on local installation) up to date? I've tried:
sbt installcrashes onbloopgun/graalvm-native-image:packageBin, sincebloopgunisn't a target anymore. I replacedbloopgunwithcliand tried to keep going...- I wanted to use the the "Generic installation (most common)" option since it is the most common, but there's no longer a
install.pyanywhere... - I next tried to use the homebrew option.
brew upgrade --build-from-source ...needed to be replaced withbrew install --build-from-source ...since I didn't originally install bloop throughbrew...- that looked like it was going through install (I see completions copied), but it ultimately errored:
Caused by: coursier.install.AppArtifacts$ScalaDependenciesNotFound: Can't find a scala version suffix for ch.epfl.scala::bloop-cli:2.0.6-77-a3a9231b-20250115-0759-SNAPSHOT (likely a non existing module or version) - Working around the above, I decided to just run the coursier command manually and it worked. Not sure why...
- However, after I made sure that was the only bloop on path, running
bloop aboutcrashed withline 2: /Users/alec/.cabal/bin/.bloop.aux: No such file or directory(ignore the dumb directory - that's just where I put thebloopproduced by coursier)
I'm not on linux or windows at the moment, so the Arch and Scoop options don't make sense.
Hmm... easiest for server is probably running cs launch ch.epfl.scala:bloop-cli_2.13:2.0.6 -M bloop.cli.Bloop -- console root replace 2.0.6 with your version after running sbt publishLocal
I updated the docs here https://github.com/scalacenter/bloop/pull/2574
Not sure about brew though, maybe it tries to install a binary version which is not available? Best probably to just test it on jar version.
Is there any progress on this? I am experiencing this, too.
Sorry, I've dropped this. I thought I had something working after my last comment, but then experienced hangs when I got to testing it. I got lost in details around how monix, manual threads, and the the command encoding was supposed to work together.
Also, I encountered different issues with bloop run that made me question slightly whether the process output forwarding in Bloop might sometimes be the root of the issue (https://github.com/scalacenter/bloop/issues/2594). In the end, it was simpler for my use case to make a utility to quickly connect over the BSP to ask for the classpath, then use that to manually start up Ammonite myself.
Looks like the subcommand is in dire need of rework, since we can't even rely on coursier being available 🤔