com-lihaoyi / mill

Mill is a fast JVM build tool that supports Java and Scala. 2-3x faster than Gradle and 5-10x faster than Maven for common workflows, Mill aims to make your project’s build process performant, maintainable, and flexible
https://mill-build.org/
MIT License
2.04k stars 331 forks source link

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

Open He-Pin opened 4 months ago

He-Pin commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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

lefou commented 4 months ago

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 commented 4 months ago

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

lefou commented 4 months ago

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 https://github.com/com-lihaoyi/mill/blob/18d14442438580975f092aa1e988cd2b696c9a13/idea/src/mill/idea/GenIdeaImpl.scala#L538, 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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

@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.

He-Pin commented 4 months ago

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

lefou commented 4 months ago

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 commented 4 months ago
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 commented 4 months ago

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 commented 3 months ago
[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 commented 3 months ago

@lefou I tried with WSL too, same problem.

He-Pin commented 1 month ago

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$