scalameta / munit

Scala testing library with actionable errors and extensible APIs
https://scalameta.org/munit
Apache License 2.0
428 stars 88 forks source link

Error when run `+publishLocal` #757

Closed He-Pin closed 4 months ago

He-Pin commented 5 months ago

image

sbt +publishLocal on windows. Java 21

SethTisue commented 5 months ago

I'm not able to reproduce the problem. This happens even on a clean checkout? I feel like there must be some information missing here.

SethTisue commented 5 months ago

Note that +publishLocal is a very big command. It's worth trying to find the minimum command actually necessary.

It appears from the error log that +compile would be sufficient to reproduce the error.

Is it reproducible without using +? That would tell us if it's specific to some Scala version (2.11, 2.12, 2.13, 3) or happens with any/all of them?

He-Pin commented 4 months ago

I will try to do this tonight, thanks.

He-Pin commented 4 months ago

With +compile on Java 21 and Winodows, still encounter this.

[error] -- [E008] Not Found Error: C:\Users\hepin\IdeaProjects\munit\munit\jvm\src\main\scala\munit\internal\PlatformCompat.scala:65:15
[error] 65 |      TimeUnit.MILLISECONDS
[error]    |      ^^^^^^^^^^^^^^^^^^^^^
[error]    |value MILLISECONDS is not a member of object java.util.concurrent.TimeUnit, but could be made available as an extension method.
[error]    |
[error]    |The following import might make progress towards fixing the problem:
[error]    |
[error]    |  import munit.Clue.generate
[error]    |
[error] -- [E008] Not Found Error: C:\Users\hepin\IdeaProjects\munit\munit\jvm\src\main\scala\munit\internal\PlatformCompat.scala:82:15
[error] 82 |      TimeUnit.MILLISECONDS
[error]    |      ^^^^^^^^^^^^^^^^^^^^^
[error]    |value MILLISECONDS is not a member of object java.util.concurrent.TimeUnit, but could be made available as an extension method.
[error]    |
[error]    |The following import might make progress towards fixing the problem:
[error]    |
[error]    |  import munit.Clue.generate
[error]    |
[error] -- [E008] Not Found Error: C:\Users\hepin\IdeaProjects\munit\munit\shared\src\main\scala\munit\FunSuite.scala:49:63
[error] 49 |  def munitTimeout: Duration = new FiniteDuration(30, TimeUnit.SECONDS)
[error]    |                                                      ^^^^^^^^^^^^^^^^
[error]    |value SECONDS is not a member of object java.util.concurrent.TimeUnit, but could be made available as an extension method.
[error]    |
[error]    |The following import might make progress towards fixing the problem:
[error]    |
[error]    |  import munit.Clue.generate
[error]    |
[error] 6 errors found
[error] (munitNative / Compile / compileIncremental) Compilation failed
[error] (munitJVM / Compile / compileIncremental) Compilation failed
[error] (munitJS / Compile / compileIncremental) Compilation failed
[error] Total time: 136 s (02:16), completed 2024年4月10日 11:27:27

But sbt compile success

SethTisue commented 4 months ago

okay, so + cycles through a bunch of Scala versions. which of the Scala versions is the one that's the problem?

He-Pin commented 4 months ago

++3.3.3 and compile will cause error. 2.12 and 2.13 works

SethTisue commented 4 months ago

currently the repo is on Scala 3.1.2, not 3.3.3. is the problem reproducible on 3.1.2?

SethTisue commented 4 months ago

I suspect what's happening here is that ++3.3.3 doesn't get you 3.3.3 without !, you have to ++3.3.3!

And the problem is reproducible on MacOS on 3.1.2, probably because 3.1.2 doesn't support JDK 21?

So I think what needs to happen here is for https://github.com/scalameta/munit/pull/733 to be merged and the problem will go away. In the meantime, ++3.3.3! should allow you to compile the project.

SethTisue commented 4 months ago

by the way, when I say the problem is reproducible on macOS, in the error log the "not found" compile errors are preceded by

[error] error while loading ElementType,
[error] class file /modules/java.base/java/lang/annotation/ElementType.class is broken, reading aborted with class java.lang.RuntimeException
[error] bad constant pool index: 0 at pos: 1220
[error] error while loading RetentionPolicy,
[error] class file /modules/java.base/java/lang/annotation/RetentionPolicy.class is broken, reading aborted with class java.lang.RuntimeException
[error] bad constant pool index: 0 at pos: 935

these errors are the essential clue to the nature of the problem. the stuff that comes later ("value MILLISECONDS is not a member of object java.util.concurrent.TimeUnit" and so on) is just consequences

mzuehlke commented 4 months ago

In scope of #761 the scala 3 version got raised to 3.3.3. So this issue can be clsoed.