oyvindberg / bleep

A bleeping fast scala build tool!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bleep import fails unexpectedly

kpodsiad opened this issue · comments

Hey @oyvindberg! I wanted to try bleep, but I have encountered problem when importing sbt build. I can take a look at problem, but is there some sort of contributing guide which describes basic worfklow when working with bleep itself? I'll start playing with it anyway in case you didn't manage to read this issue. Have a good day!

Stack trace

 command failed unexpectedly java.nio.charset.MalformedInputException: Input length = 1
        at java.base@17.0.6/java.lang.String.throwMalformed(String.java:1238)
        at java.base@17.0.6/java.lang.String.decodeUTF8_UTF16(String.java:1189)
        at java.base@17.0.6/java.lang.String.newStringUTF8NoRepl(String.java:726)
        at java.base@17.0.6/java.lang.String.newStringNoRepl1(String.java:754)
        at java.base@17.0.6/java.lang.String.newStringNoRepl(String.java:736)
        at java.base@17.0.6/java.lang.System$2.newStringNoRepl(System.java:2390)
        at java.base@17.0.6/java.nio.file.Files.readString(Files.java:3369)
        at java.base@17.0.6/java.nio.file.Files.readString(Files.java:3325)
        at bleep.sbtimport.ImportInputData$.findFiles$1$$anonfun$2$$anonfun$2(ImportInputData.scala:160)
        at scala.collection.Iterator$$anon$9.next(Iterator.scala:584)
        at scala.collection.Iterator$$anon$10.next(Iterator.scala:618)
        at scala.collection.immutable.List.prependedAll(List.scala:156)
        at scala.collection.immutable.List$.from(List.scala:684)
        at scala.collection.immutable.List$.from(List.scala:681)
        at scala.collection.IterableOps$WithFilter.flatMap(Iterable.scala:901)
        at bleep.sbtimport.ImportInputData$.findFiles$1(ImportInputData.scala:160)
        at bleep.sbtimport.ImportInputData$.$anonfun$17(ImportInputData.scala:163)
        at scala.collection.StrictOptimizedIterableOps.flatMap(StrictOptimizedIterableOps.scala:118)
        at scala.collection.StrictOptimizedIterableOps.flatMap$(StrictOptimizedIterableOps.scala:105)
        at scala.collection.immutable.Vector.flatMap(Vector.scala:113)
        at bleep.sbtimport.ImportInputData$.collectFromFileSystem(ImportInputData.scala:164)
        at bleep.commands.Import.run(Import.scala:23)
        at bleep.Main$.$anonfun$41$$anonfun$1$$anonfun$1(Main.scala:477)
        at bleep.Main$.run$$anonfun$1(Main.scala:546)
        at scala.util.Try$.apply(Try.scala:210)
        at bleep.Main$.run(Main.scala:546)
        at bleep.Main$.$anonfun$41$$anonfun$1(Main.scala:477)
        at bleep.logging.TypedLoggerResource$.bleep$logging$TypedLoggerResource$Ops$$anon$4$$_$use$$anonfun$4(TypedLoggerResource.scala:41)
        at bleep.logging.TypedLoggerResource$Ops$$anon$1.use$$anonfun$1(TypedLoggerResource.scala:20)
        at bleep.logging.TypedLoggerResource$.bleep$logging$TypedLoggerResource$Ops$$anon$3$$_$use$$anonfun$3$$anonfun$1(TypedLoggerResource.scala:34)
        at bleep.logging.TypedLoggerResource$$anon$6.use(TypedLoggerResource.scala:56)
        at bleep.logging.TypedLoggerResource$Ops$$anon$3.use$$anonfun$3(TypedLoggerResource.scala:34)
        at bleep.logging.TypedLoggerResource$Ops$$anon$1.use$$anonfun$1(TypedLoggerResource.scala:20)
        at bleep.logging.TypedLoggerResource$$anon$7.use(TypedLoggerResource.scala:67)
        at bleep.logging.TypedLoggerResource$Ops$$anon$1.use(TypedLoggerResource.scala:20)
        at bleep.logging.TypedLoggerResource$Ops$$anon$3.use(TypedLoggerResource.scala:36)
        at bleep.logging.TypedLoggerResource$Ops$$anon$1.use(TypedLoggerResource.scala:20)
        at bleep.logging.TypedLoggerResource$Ops$$anon$4.use(TypedLoggerResource.scala:41)
        at bleep.Main$.$anonfun$41(Main.scala:484)
        at bleep.ExitCode.andThen(ExitCode.scala:6)
        at bleep.Main$.main(Main.scala:486)
        at bleep.Main.main(Main.scala)

Hey there, thanks for you interest in looking into it! :)

No there isn't I guess, except for this section in the readme. The way I see it, bleep is a normal JVM program. Of course it manages a bloop server which complicates things, and it's ultimately compiled to a graalvm image but you can typically ignore that.

So how to start then? mount the bleep codebase in your IDE like intellij, and start bleep.Main. set current working directory (in intellij run config or by adding a parameter -d ../some/other/dir). Then start it in debug mode and set breakpoints, and you should hopefully be able to navigate from there.

So in this case I think the problem looks somewhat obvious, the import code tries to read all generated source and resourcesfiles as UTF-8 encoded strings. if you have an sbt plugin which generates binary files, or at least non-UTF-8 encoded text files, this seems likely to blow up.

I'm not entirely sure what to do about it btw. we could add a simple try/catch and just complain with a warning for these files, as I think it's a rather niche case (though curious to know what causes it on your side, maybe I'm not right about that).

The user flow here is that the sbt import generates a script which can replicate the generated (re-)sources the sbt build produced - but in a frozen state. You're meant to reimplement that script to generate the files properly into the destinations you can see in the script. That's why it's probably not an emergency if that stopgap script is not 100% complete.

If we want to do better we'll probably need to split the GeneratedFile structure into one for sources and one for resources. The reason why it's really beneficial to keep the generated sources in text form is that some string replacement of paths is done to them so that the snapshot tests bleep uses are portable between machines (see ).

The snap

Cool, I already saw readme and because I'm familiar with BSP and scala-cli setup-ide part was easy ;) Unfortunately, something is off, I cloned fresh instance of repo and this is what I got as a result of bleep compile bleep-core@jvm213.

Details

➜  bleep2 git:(master) bleep compile bleep-core@jvm213
📙 Launching Bleep version 0.0.2 for ARM64 because you ran the AMD64 build. This is probably because you're running coursier compiled for AMD64. You can either try the coursier M1 runner at https://github.com/VirtusLab/coursier-m1 , or download and install bleep manually. Note that bleep will work this way, but startup will be slower.
📙 Refreshing /../bleep2/.bleep/builds/normal/.bloop...
📗 wrote bloop files [value => New: 39]
📗 bootstrapped in 223 ms
📗 Running source generator `bleep.scripts.GenerateResources` for project bleep-model@jvm213 because output didn't exist
📗 BSP / [script GenerateResources]: bootstrapped in 217 ms
📙 BSP / [script GenerateResources]: Writing /../bleep2/.bleep/generated-sources/bleep-model@jvm213/bleep.scripts.GenerateResources/bleep/model/BleepVersion.scala [target.project => bleep-model@jvm213]
📙 BSP / [script GenerateResources]: Writing /../bleep2/.bleep/generated-sources/bleep-model@jvm213/bleep.scripts.GenerateResources/bleep/model/Jvm.scala [target.project => bleep-model@jvm213]
📗 Run bleep.scripts.GenerateResources succeeded
📕 BSP: bleep-core@jvm213 object davidgregory084 is not a member of package io.github [value => file:///../bleep2/bleep-core/src/scala/bleep/GenBloopFiles.scala:8:7 until 8:32]

it's a rather niche case (though curious to know what causes it on your side, maybe I'm not right about that)

I'll try to examinate project and build on its own today or tomorrow.

Did you git clone --recurse-submodules ... ?