`import $meta` results in `java.lang.IndexOutOfBoundsException`
tballard opened this issue · comments
Here's a stack trace for you. It looked like a case where the stack was all the information you needed to implement a fix.
Version: 0.11.7
mill resolve _
An unexpected error occurred
Exception in thread "MillServerActionRunner" java.lang.IndexOutOfBoundsException: 0
at scala.collection.LinearSeqOps.apply(LinearSeq.scala:131)
at scala.collection.LinearSeqOps.apply$(LinearSeq.scala:128)
at scala.collection.immutable.List.apply(List.scala:79)
at mill.runner.Parsers$.$anonfun$parseImportHooksWithIndices$3(Parsers.scala:76)
at scala.collection.immutable.List.foreach(List.scala:333)
at mill.runner.Parsers$.$anonfun$parseImportHooksWithIndices$1(Parsers.scala:75)
at scala.collection.immutable.List.foreach(List.scala:333)
at mill.runner.Parsers$.parseImportHooksWithIndices(Parsers.scala:67)
at mill.runner.FileImportGraph$.walkScripts$1(FileImportGraph.scala:73)
at mill.runner.FileImportGraph$.parseBuildFiles(FileImportGraph.scala:131)
at mill.runner.MillBuildBootstrap.evaluateRec(MillBuildBootstrap.scala:96)
at mill.runner.MillBuildBootstrap.state$lzycompute$1(MillBuildBootstrap.scala:78)
at mill.runner.MillBuildBootstrap.state$1(MillBuildBootstrap.scala:78)
at mill.runner.MillBuildBootstrap.evaluateRec(MillBuildBootstrap.scala:79)
at mill.runner.MillBuildBootstrap.$anonfun$evaluate$1(MillBuildBootstrap.scala:49)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
at mill.runner.MillBuildBootstrap.evaluate(MillBuildBootstrap.scala:48)
at mill.runner.MillMain$.$anonfun$main0$6(MillMain.scala:234)
at mill.runner.Watching$.watchLoop(Watching.scala:27)
at mill.runner.MillMain$.$anonfun$main0$1(MillMain.scala:219)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
at scala.Console$.withErr(Console.scala:193)
at mill.api.SystemStreams$.$anonfun$withStreams$2(SystemStreams.scala:62)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
at scala.Console$.withOut(Console.scala:164)
at mill.api.SystemStreams$.$anonfun$withStreams$1(SystemStreams.scala:61)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
at scala.Console$.withIn(Console.scala:227)
at mill.api.SystemStreams$.withStreams(SystemStreams.scala:60)
at mill.runner.MillMain$.main0(MillMain.scala:101)
at mill.runner.MillServerMain$.main0(MillServerMain.scala:83)
at mill.runner.MillServerMain$.main0(MillServerMain.scala:35)
at mill.runner.Server.$anonfun$handleRun$1(MillServerMain.scala:187)
at java.base/java.lang.Thread.run(Thread.java:833)
Can you also post a snippet of the file which causes that, so we can also learn something?
I had to change the file type to .txt to attach it. The tests are commented out because I was working on them recently and I was trying to back up to where things worked again. The tests were actually working for awhile before this started happening. It also happens if I try to build in the mill-build directory, not that I normally do that. It still breaks despite all the commenting, and if I blow away the out directory. 0.11.6 also fails. A different project still builds, anyway. I was thinking of rebooting out of desperation.
Looks like this import is the issue:
import $meta
Once, I fix it,
-import $meta
+import $meta._
the error goes away, though, I can't run due to the missing meta-build.
Sweet. I see that my comment was right. For some reason, intellij has a habit of deleting that line and I guess my cutting and pasting finger was tired.
Here is a reproducer:
// file: build.sc
import $meta
import mill._
object root extends RootModule
> mill resolve _
An unexpected error occurred
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at mill.main.client.IsolatedMillMainLoader.runMain(IsolatedMillMainLoader.java:58)
at mill.main.client.MillClientMain.main(MillClientMain.java:78)
Caused by: java.lang.IndexOutOfBoundsException: 0
at scala.collection.LinearSeqOps.apply(LinearSeq.scala:131)
at scala.collection.LinearSeqOps.apply$(LinearSeq.scala:128)
at scala.collection.immutable.List.apply(List.scala:79)
at mill.runner.Parsers$.$anonfun$parseImportHooksWithIndices$3(Parsers.scala:76)
at scala.collection.immutable.List.foreach(List.scala:333)
at mill.runner.Parsers$.$anonfun$parseImportHooksWithIndices$1(Parsers.scala:75)
at scala.collection.immutable.List.foreach(List.scala:333)
at mill.runner.Parsers$.parseImportHooksWithIndices(Parsers.scala:67)
at mill.runner.FileImportGraph$.walkScripts$1(FileImportGraph.scala:73)
at mill.runner.FileImportGraph$.parseBuildFiles(FileImportGraph.scala:131)
at mill.runner.MillBuildBootstrap.evaluateRec(MillBuildBootstrap.scala:96)
at mill.runner.MillBuildBootstrap.state$lzycompute$1(MillBuildBootstrap.scala:78)
at mill.runner.MillBuildBootstrap.state$1(MillBuildBootstrap.scala:78)
at mill.runner.MillBuildBootstrap.evaluateRec(MillBuildBootstrap.scala:79)
at mill.runner.MillBuildBootstrap.$anonfun$evaluate$1(MillBuildBootstrap.scala:49)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
at mill.runner.MillBuildBootstrap.evaluate(MillBuildBootstrap.scala:48)
at mill.runner.MillMain$.$anonfun$main0$6(MillMain.scala:234)
at mill.runner.Watching$.watchLoop(Watching.scala:27)
at mill.runner.MillMain$.$anonfun$main0$1(MillMain.scala:219)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
at scala.Console$.withErr(Console.scala:193)
at mill.api.SystemStreams$.$anonfun$withStreams$2(SystemStreams.scala:62)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
at scala.Console$.withOut(Console.scala:164)
at mill.api.SystemStreams$.$anonfun$withStreams$1(SystemStreams.scala:61)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
at scala.Console$.withIn(Console.scala:227)
at mill.api.SystemStreams$.withStreams(SystemStreams.scala:60)
at mill.runner.MillMain$.main0(MillMain.scala:101)
at mill.runner.MillMain$.liftedTree1$1(MillMain.scala:78)
at mill.runner.MillMain$.main(MillMain.scala:69)
at mill.runner.MillMain.main(MillMain.scala)
... 6 more
I guess saw that line when I did my diff and mistakenly attributed it to Intellij's problem ... Looks like it should be a simple fix, anyway. Thanks for loaning your eyeballs.
I think our parser code should always fail with a nice error message, if a $
-import is found without any trailing path.
@lihaoyi Do you mind to have a look at it?