google / ksp

Kotlin Symbol Processing API
https://github.com/google/ksp
Apache License 2.0
2.83k stars 265 forks source link

Kotlin 2.0.0 and ksp 2.0.0-1.0.21: UnsatisfiedLinkError: Can't load library: .../native/jansi/1.18/osx/libjansi.jnilib #1944

Open gosr opened 3 months ago

gosr commented 3 months ago

Reproduce:

  1. Clone the Google KMP sample repo https://github.com/android/kotlin-multiplatform-samples and open "Fruitties".
  2. Bump Kotlin to 2.0.0, ksp to 2.0.0-1.0.21.
  3. Also need to bump Skie to 0.8.1 for Kotlin 2.0.0 support.
  4. See this commit for reference about the changes: https://github.com/gosr/kotlin-multiplatform-samples/commit/00096ae82116fb17761a7bbabb416a5ff40739c5
  5. Run the iOS app.

Result:

> Task :shared:compileKotlinIosSimulatorArm64 FAILED
Failed to load native library:libjansi.jnilib. The native library file at /Users/<user>/.gradle/native/jansi/1.18/osx/libjansi.jnilib is not executable, make sure that the directory is mounted on a partition without the noexec flag, or set the jansi.tmpdir system property to point to a proper location.  osinfo: Mac/arm64
java.lang.UnsatisfiedLinkError: Can't load library: /Users/<user>/.gradle/native/jansi/1.18/osx/libjansi.jnilib
/Users/<user>/repos/_forks/kotlin-multiplatform-samples/Fruitties/shared/src/nativeMain/kotlin/com/example/fruitties/di/Factory.native.kt:23:39: error: Unresolved reference 'instantiateImpl'.
/Users/<user>/repos/_forks/kotlin-multiplatform-samples/Fruitties/shared/src/nativeMain/kotlin/com/example/fruitties/di/Factory.native.kt:38:45: error: Unresolved reference 'instantiateImpl'.
error: Process 'command '/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

Looks like it also fails to generate the necessary native code.

It works fine without the changes done in https://github.com/gosr/kotlin-multiplatform-samples/commit/00096ae82116fb17761a7bbabb416a5ff40739c5.

ionspin commented 3 months ago

I think this is also duplicate of #1940 The files are generated in build folder but for some reason not accessible during compilation phase.

danysantiago commented 1 month ago

I actually think this is because of the following upstream issue: https://youtrack.jetbrains.com/issue/KT-69523

If you have kotlin.native.disableCompilerDaemon = true, please remove the property line or set it to false when using Kotlin 2.0