Kotlin / kotlinx.serialization

Kotlin multiplatform / multi-format serialization
Apache License 2.0
5.41k stars 620 forks source link

Build fails on master #2663

Closed timmc closed 5 months ago

timmc commented 6 months ago

Describe the bug

Running the documented ./gradlew build on master fails. (However, ./gradlew jvmTest succeeds.)

To Reproduce

  1. Checked out master branch (currently e6fb4402da80)
  2. Ran ./gradlew build

Two JS-related targets fail to compile:

> Task :kotlinx-serialization-core:compileKotlinJs
e: Could not load module <org.jetbrains.kotlinx:kotlinx-serialization-core> in an attempt to find deserializer for symbol kotlinx.serialization.internal/createSimpleEnumSerializer|createSimpleEnumSerializer(kotlin.String;kotlin.Array<0:0>){0§<kotlin.Enum<0:0>>}[0].

> Task :kotlinx-serialization-core:compileKotlinJs FAILED

> Task :kotlinx-serialization-core:compileKotlinWasmJs
e: Could not load module <org.jetbrains.kotlinx:kotlinx-serialization-core> in an attempt to find deserializer for symbol kotlinx.serialization.internal/createSimpleEnumSerializer|createSimpleEnumSerializer(kotlin.String;kotlin.Array<0:0>){0§<kotlin.Enum<0:0>>}[0].

> Task :kotlinx-serialization-core:compileKotlinWasmJs FAILED

Full output: gradle.log

Expected behavior

Project should build.

Environment

timmc commented 6 months ago

Shutting down IntelliJ IDEA first and running ./gradlew clean build gives a different error (also present on v1.6.3):

> Task :guide:test

example.test.SerializersTest > testExampleSerializer18 FAILED
    java.lang.Exception at SerializersTest.kt:129

120 tests completed, 1 failed

So the first one I saw may have been spurious, but there's still a build failure here.

sandwwraith commented 6 months ago

The compileKotlinJs fail is a known flaky issue of incremental compilation. It usually pops out when you switch branches that were too far apart. :kotlinx-serialization-core:clean usually makes the problem go away

sandwwraith commented 6 months ago

For ./gradlew :guide:test — I've tested both master and v.1.6.3, and they're passing fine (CI also shows the same: https://teamcity.jetbrains.com/buildConfiguration/KotlinTools_KotlinxSerialization_RuntimeLibraryBuildAggregated?branch=%3Cdefault%3E&buildTypeTab=overview&mode=builds).

However, given that this test is related to the date formatting, maybe there's an issue connected with the default locale on your machine. Can you please send a full exception text so I can check it?

timmc commented 6 months ago

Oh yes, that's definitely a locale issue!

java.lang.Exception: Output is not the same as expected, difference is
-------------------------------------------
1c1
< {"stableReleaseDate":"2016-02-15","lastReleaseTimestamp":1657152000000}
---
> {"stableReleaseDate":"2016-02-14","lastReleaseTimestamp":1657152000000}
-------------------------------------------
    at kotlinx.knit.test.KnitTestKt.verifyOutputLines(KnitTest.kt:60)
    at example.test.SerializersTest.testExampleSerializer18(SerializersTest.kt:129)

format.parse("2016-02-15+00") gives Sun Feb 14 19:00:00 EST 2016 on my machine, and yes, I'm in the US Eastern locale. The example code should probably be updated to ensure a specific locale is used for serialization—I'd be happy to put in a PR that just sets the time zone to UTC on the formatter.

timmc commented 6 months ago

I've filed https://github.com/Kotlin/kotlinx.serialization/pull/2664 for the date formatting issue. With that fixed, I can complete the build!