Skip to content
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

MatchError when do mill.idea.GenIdea/idea #3168

Closed
He-Pin opened this issue May 19, 2024 · 18 comments · Fixed by #3754
Closed

MatchError when do mill.idea.GenIdea/idea #3168

He-Pin opened this issue May 19, 2024 · 18 comments · Fixed by #3754
Labels
bug The issue represents an bug
Milestone

Comments

@He-Pin
Copy link
Contributor

He-Pin commented May 19, 2024

Error when call mill mill.idea.GenIdea/idea on cask.

Mill version: the latest snapshot: 0.11.7-86-18d144

1 targets failed
mill.idea.GenIdea.idea scala.MatchError: Vector(Vector(ref:v0:c984eca8:C:\Users\hepin\IdeaProjects\cask\example\twirl\app\resources)) (of class scala.collection.immutable.Vector1)
    mill.idea.GenIdeaImpl.$anonfun$xmlFileLayout$100(GenIdeaImpl.scala:538)
    scala.collection.immutable.List.map(List.scala:250)
    scala.collection.immutable.List.map(List.scala:79)
    mill.idea.GenIdeaImpl.xmlFileLayout(GenIdeaImpl.scala:512)
    mill.idea.GenIdeaImpl.run(GenIdeaImpl.scala:38)
  1. Call ` mill.stdlib.GenIdea/idea`` works.
  2. Call ./mill mill.scalalib.GenIdea/idea works too, but IDEA can recognize it.
  3. comments out twirl module works too
@lefou
Copy link
Member

lefou commented May 21, 2024

I can't reproduce:

> git clone https://github.com/com-lihaoyi/cask
Klone nach 'cask'...
remote: Enumerating objects: 5408, done.
remote: Counting objects: 100% (989/989), done.
remote: Compressing objects: 100% (479/479), done.
remote: Total 5408 (delta 418), reused 932 (delta 379), pack-reused 4419
Empfange Objekte: 100% (5408/5408), 747.54 KiB | 4.30 MiB/s, fertig.
Löse Unterschiede auf: 100% (2241/2241), fertig.
> cd cask
> echo -n "0.11.7-86-18d144" > .mill-version
> mill mill.idea.GenIdea/idea
[build.sc] [53/58] compile 
Compiling compiler interface...
[info] compiling 27 Scala sources to /home/lefou/work/tmp/cask/out/mill-build/compile.dest/classes ...
[warn] /home/lefou/work/tmp/cask/example/staticFiles/build.sc:19:7: reference to test is ambiguous;
[warn] it is both defined in the enclosing trait AppModule and inherited in the enclosing object test as method test (defined in trait TestModule, inherited through parent trait ScalaTests)
[warn] In Scala 2, symbols inherited from a superclass shadow symbols defined in an outer scope.
[warn] Such references are ambiguous in Scala 3. To continue using the inherited symbol, write `this.test`.
[warn] Or use `-Wconf:msg=legacy-binding:s` to silence this warning. [quickfixable]
[warn]       test(args:_*)
[warn]       ^
[warn] /home/lefou/work/tmp/cask/example/staticFiles2/build.sc:19:7: reference to test is ambiguous;
[warn] it is both defined in the enclosing trait AppModule and inherited in the enclosing object test as method test (defined in trait TestModule, inherited through parent trait ScalaTests)
[warn] In Scala 2, symbols inherited from a superclass shadow symbols defined in an outer scope.
[warn] Such references are ambiguous in Scala 3. To continue using the inherited symbol, write `this.test`.
[warn] Or use `-Wconf:msg=legacy-binding:s` to silence this warning. [quickfixable]
[warn]       test(args:_*)
[warn]       ^
[warn] two warnings found
[info] done compiling
[1/1] mill.idea.GenIdea.idea 
Analyzing modules ...
[build.sc] [1/1] mill.idea.GenIdea.idea > [7/9] sources.super.mill.scalalib.JavaModule.sources 
Writing 502 IDEA project files to /home/lefou/work/tmp/cask/.idea ...

I also can't make any sense of your other comments. Maybe, you have some local changes? Can you elaborate?

@He-Pin
Copy link
Contributor Author

He-Pin commented May 21, 2024

Thanks for look in,There is a pr in the cask repo, you can check it out. And I'm using windows 11.

@lefou
Copy link
Member

lefou commented May 21, 2024

Please provide the link to the PR. I see two.

> gh pr list
Showing 3 of 3 open pull requests in com-lihaoyi/cask

#125  Virtual Thread support         He-Pin:vt                about 1 day ago
#124  chore: Rename page 1           He-Pin:patch-1           about 1 day ago
#113  [WIP] Better route validation  better-route-validation  about 4 months ago

@He-Pin
Copy link
Contributor Author

He-Pin commented May 28, 2024

@lefou com-lihaoyi/cask#125
I'm on Windows 11, and using mill from Windows shell , not WSL.

@lefou
Copy link
Member

lefou commented May 28, 2024

I still can't reproduce on my Linux machine.

But the stacktrace/error message you've shown doesn't make sense to me, since it points me to

case (_, true, false) => Some("PROVIDED")
, which isn't even supposed to match on a Vector of PathRef.

Does running with --debug reveal anything?
Can you show mill --meta-level 1 show runClasspath?
Are your projects dir and home dir on the same drive/filesystem?
How have you installed Mill?

@Amagicman
Copy link

hang@vm:~/work/lx00lib/mill$ mill mill.idea.GenIdea/idea
Mill version 0.11.7 is different than configured for this directory!
Configured version is 0.11.7-17-17dea9 (/home/hang/work/lx00lib/mill/.config/mill-version)
[1/1] mill.idea.GenIdea.idea
Analyzing modules ...
[1/1] mill.idea.GenIdea.idea > [5/38] millLastTag
1 targets failed
mill.idea.GenIdea.idea scala.MatchError: Vector() (of class scala.collection.immutable.Vector0$)
mill.idea.GenIdeaImpl.$anonfun$xmlFileLayout$100(GenIdeaImpl.scala:538)
scala.collection.immutable.List.map(List.scala:250)
scala.collection.immutable.List.map(List.scala:79)
mill.idea.GenIdeaImpl.xmlFileLayout(GenIdeaImpl.scala:512)
mill.idea.GenIdeaImpl.run(GenIdeaImpl.scala:38)

I also encountered this issue on the Ubuntu system running on my virtual machine, which cannot be resolved

@Amagicman
Copy link

hang@vm:~/work/lx00lib/rocket-chip$ make verilog
cd /home/hang/work/lx00lib/rocket-chip && mill emulator[freechips.rocketchip.system.TestHarness,freechips.rocketchip.system.DefaultConfig].mfccompiler.compile
Compiling /home/hang/work/lx00lib/rocket-chip/build.sc
build.sc:588: not found: value Cross
trait JTAGDTMTest extends Cross.Module5[String, String, String, String, String] {
^
build.sc:462: not found: value Cross
trait ArchTest extends Cross.Module4[String, String, String, String] {
^
build.sc:434: not found: value Cross
trait RiscvTest extends Cross.Module4[String, String, String, String] {
^
build.sc:113: not found: value Cross
trait Emulator extends Cross.Module2[String, String] {
^
build.sc:68: not found: value millbuild
extends millbuild.common.RocketChipModule
^
build.sc:71: not found: value Cross
with Cross.Module[String] {
^
build.sc:56: not found: value millbuild
extends millbuild.cde.common.CDEModule
^
build.sc:36: not found: value millbuild

at the same time my mill's Cross cant work

@lefou
Copy link
Member

lefou commented Jun 1, 2024

@Amagicman Your last comment looks totally unrelated. Please make sure your build.sc doesn't contain other errors. E.g. some mill resolve __.compile should provide all compile targets in your project, not an error.

@lefou lefou added the need-more-info More information is needed to reproduce or fix the issue label Jun 1, 2024
@He-Pin
Copy link
Contributor Author

He-Pin commented Jun 1, 2024

@lefou the twril part is commented out, you need turn it on to reproduce that issue.

@lefou
Copy link
Member

lefou commented Jun 1, 2024

Still not reproducible.

> git diff
diff --git a/.mill-version b/.mill-version
index 2b96086..429ca70 100644
--- a/.mill-version
+++ b/.mill-version
@@ -1 +1 @@
- 0.11.7-107-9ec9bc
+0.11.7-107-9ec9bc
diff --git a/build.sc b/build.sc
index 397e947..c7daf5b 100644
--- a/build.sc
+++ b/build.sc
@@ -168,7 +168,7 @@ object example extends Module{
   object todoDb extends Cross[TodoDbModule](scala213) // uses quill, can't enable for Dotty yet
 
   trait TwirlModule extends millbuild.example.twirl.build.AppModule with LocalModule
-//  object twirl extends Cross[TwirlModule](scalaVersions)
+  object twirl extends Cross[TwirlModule](scalaVersions)
 
   trait VariableRoutesModule extends millbuild.example.variableRoutes.build.AppModule with LocalModule
   object variableRoutes extends Cross[VariableRoutesModule](scalaVersions)
> mill --version
Mill Build Tool version 0.11.7-107-9ec9bc
Java version: 17.0.10, vendor: Eclipse Adoptium, runtime: /opt/openjdk-bin-17.0.10_p7
Default locale: de_DE, platform encoding: UTF-8
OS name: "Linux", version: 6.1.74-gentoo-x86_64, arch: amd64

> mill -i mill.idea.GenIdea/idea
[1/1] mill.idea.GenIdea.idea 
Analyzing modules ...
[1/1] mill.idea.GenIdea.idea > [5/6] example.websockets4[3.3.3].test.sources 
Writing 501 IDEA project files to /home/lefou/work/tmp/cask/.idea ...

@He-Pin
Copy link
Contributor Author

He-Pin commented Jun 2, 2024

PS C:\Users\hepin\IdeaProjects\cask> mill --meta-level 1 show runClasspath
Mill version 0.11.7 is different than configured for this directory!
Configured version is 0.11.7-109-59a5cb (C:\Users\hepin\IdeaProjects\cask\.mill-version)   
[build.sc] [1/1] show > [47/51] zincReportCachedProblems
[
  "qref:v1:53cf50f2:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.maven.org\\maven2\\com\\lihaoyi\\os-lib_2.13\\0.8.1\\os-lib_2.13-0.8.1.jar",
  "qref:v1:565a2c8b:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.mav
en.org\\maven2\\de\\tototec\\de.tobiasroeser.mill.vcs.version_mill0.11_2.13\\0.4.0\\de.tobiasroeser.mill.vcs.version_mill0.11_2.13-0.4.0.jar",
  "qref:v1:4f8f7ce9:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.mav
en.org\\maven2\\com\\lihaoyi\\mill-contrib-twirllib_2.13\\0.11.7\\mill-contrib-twirllib_2.13-0.11.7.jar",
  "qref:v1:c9379904:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.mav
en.org\\maven2\\com\\github\\lolgab\\mill-mima_mill0.11_2.13\\0.1.0\\mill-mima_mill0.11_2.13-0.1.0.jar",
  "qref:v1:7070eb2e:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.mav
en.org\\maven2\\com\\lihaoyi\\mill-moduledefs_2.13\\0.10.9\\mill-moduledefs_2.13-0.10.9.jar",
  "qref:v1:1c857655:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.maven.org\\maven2\\org\\scala-lang\\scala-library\\2.13.12\\scala-library-2.13.12.jar",       
  "qref:v1:2cd29d03:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.maven.org\\maven2\\com\\lihaoyi\\geny_2.13\\0.7.1\\geny_2.13-0.7.1.jar",
  "qref:v1:c18cbcee:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.mav
en.org\\maven2\\com\\github\\lolgab\\mill-mima-worker-api_2.13\\0.1.0\\mill-mima-worker-api_2.13-0.1.0.jar",
  "qref:v1:f5873f79:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.maven.org\\maven2\\org\\scala-lang\\scala-compiler\\2.13.12\\scala-compiler-2.13.12.jar",     
  "qref:v1:4a8b347b:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.maven.org\\maven2\\com\\lihaoyi\\sourcecode_2.13\\0.3.0\\sourcecode_2.13-0.3.0.jar",
  "qref:v1:2bc24408:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.maven.org\\maven2\\org\\scala-lang\\scala-reflect\\2.13.12\\scala-reflect-2.13.12.jar",       
  "qref:v1:181ca472:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.mav
en.org\\maven2\\io\\github\\java-diff-utils\\java-diff-utils\\4.12\\java-diff-utils-4.12.jar",
  "qref:v1:fa0f0f70:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.maven.org\\maven2\\org\\jline\\jline\\3.22.0\\jline-3.22.0.jar",
  "qref:v1:5f26dd08:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.maven.org\\maven2\\net\\java\\dev\\jna\\jna\\5.13.0\\jna-5.13.0.jar",
  "ref:v0:c984eca8:C:\\Users\\hepin\\IdeaProjects\\cask\\mill-build\\compile-resources",   
  "qref:v0:49e75042:C:\\Users\\hepin\\IdeaProjects\\cask\\out\\mill-launcher\\0.11.7.jar", 
  "qref:v1:9aac14a2:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.mav
en.org\\maven2\\com\\lihaoyi\\mill-runner-linenumbers_2.13\\0.11.7\\mill-runner-linenumbers_2.13-0.11.7.jar",
  "qref:v1:f5873f79:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.maven.org\\maven2\\org\\scala-lang\\scala-compiler\\2.13.12\\scala-compiler-2.13.12.jar",     
  "qref:v1:1c857655:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.maven.org\\maven2\\org\\scala-lang\\scala-library\\2.13.12\\scala-library-2.13.12.jar",       
  "qref:v1:7070eb2e:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.mav
en.org\\maven2\\com\\lihaoyi\\mill-moduledefs_2.13\\0.10.9\\mill-moduledefs_2.13-0.10.9.jar",
  "qref:v1:2bc24408:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.maven.org\\maven2\\org\\scala-lang\\scala-reflect\\2.13.12\\scala-reflect-2.13.12.jar",       
  "qref:v1:181ca472:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.mav
en.org\\maven2\\io\\github\\java-diff-utils\\java-diff-utils\\4.12\\java-diff-utils-4.12.jar",
  "qref:v1:fa0f0f70:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.maven.org\\maven2\\org\\jline\\jline\\3.22.0\\jline-3.22.0.jar",
  "qref:v1:5f26dd08:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.maven.org\\maven2\\net\\java\\dev\\jna\\jna\\5.13.0\\jna-5.13.0.jar",
  "qref:v1:4a8b347b:C:\\Users\\hepin\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.maven.org\\maven2\\com\\lihaoyi\\sourcecode_2.13\\0.3.0\\sourcecode_2.13-0.3.0.jar",
  "ref:v0:5d44b286:C:\\Users\\hepin\\IdeaProjects\\cask\\out\\mill-build\\compile.dest\\classes"
]

@lefou run with mill --meta-level 1 show runClasspath

@lefou
Copy link
Member

lefou commented Jun 2, 2024

I see an rather old os-lib in the classpath, which may collide with what Mill already provided. Also some duplicate java-diff-uitls, jline, jna and sourcecode jars. I don't expect those to be the cause, but it's probably worth to fix anyways.

@He-Pin
Copy link
Contributor Author

He-Pin commented Jul 2, 2024

[1/1] mill.idea.GenIdea.idea > [10/14] example.twirl[2.12.19].compileTwirl
1 targets failed
mill.idea.GenIdea.idea scala.MatchError: Vector(Vector(ref:v0:c984eca8:C:\Users\hepin\IdeaProjects\cask\example\twirl\app\resources)) (of class scala.collection.immutable.Vector1)
    mill.idea.GenIdeaImpl.$anonfun$xmlFileLayout$101(GenIdeaImpl.scala:516)
    scala.collection.immutable.List.flatMap(List.scala:294)
    scala.collection.immutable.List.flatMap(List.scala:79)
    mill.idea.GenIdeaImpl.xmlFileLayout(GenIdeaImpl.scala:489)
    mill.idea.GenIdeaImpl.run(GenIdeaImpl.scala:37)

I tested it with the latest version 0.11.8, same error.

@He-Pin
Copy link
Contributor Author

He-Pin commented Jul 2, 2024

@lefou I tried with WSL too, same problem.

@He-Pin
Copy link
Contributor Author

He-Pin commented Sep 2, 2024

With mill 0.11.12

mill.idea.GenIdea.idea scala.MatchError: Vector(Vector(ref:v0:c984eca8:C:\Users\hepin\IdeaProjects\cask\example\twirl\app\resources)) (of class scala.collection.immutable.Vector1) 
    mill.idea.GenIdeaImpl.$anonfun$xmlFileLayout$97(GenIdeaImpl.scala:510)
    scala.collection.immutable.List.flatMap(List.scala:294)
    scala.collection.immutable.List.flatMap(List.scala:79)
    mill.idea.GenIdeaImpl.xmlFileLayout(GenIdeaImpl.scala:483)
    mill.idea.GenIdeaImpl.run(GenIdeaImpl.scala:39)
hepin@LAPTOP-057IVKOG:/mnt/c/Users/hepin/IdeaProjects/cask$ 

@lefou
Copy link
Member

lefou commented Oct 16, 2024

I think I now have an idea what's happening. The code at the stack trace location assumes the result of evaluate is always successful. If not, we don't see an error message and the resulting Seq might not have the right size, resulting in the match error.

@lefou
Copy link
Member

lefou commented Oct 16, 2024

Instead, a evalOrThrow should be used as in other locations.

@lefou lefou added bug The issue represents an bug and removed need-more-info More information is needed to reproduce or fix the issue platform-windows labels Oct 16, 2024
@lefou
Copy link
Member

lefou commented Oct 16, 2024

@He-Pin I have a fix ready. But I wonder why you didn't see the issue when building the project from cli?

@lefou lefou closed this as completed in c2d1c54 Oct 16, 2024
@lefou lefou added this to the 0.12.0 milestone Oct 16, 2024
lefou added a commit to lefou/mill that referenced this issue Oct 16, 2024
…kport com-lihaoyi#3754)

We simply don't swallow the error but propagate it.

Fix com-lihaoyi#3168

Backport of pull request: com-lihaoyi#3754
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue represents an bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants