compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

Failed to load native library:libjansi.jnilib.

Open mahramane opened this issue 1 year ago • 8 comments

Describe the bug In Fleet when i run ios project, it gives me following error:

Failed to load native library:libjansi.jnilib. The native library file at /Users/mohammad/.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/mohammad/.gradle/native/jansi/1.18/osx/libjansi.jnilib

Also i add kotlin.native.disableCompilerDaemon = true to gradle.properties.

Affected platforms

  • iOS

Versions

  • Libraries:
    • Compose Multiplatform version: 1.6.11
  • Kotlin version: 2.0.0
  • OS version(s) (required for Desktop and iOS issues): IOS
  • OS architecture (x86 or arm64): arm64
  • Device (model or simulator for iOS issues): iphone 15

mahramane avatar Jun 05 '24 06:06 mahramane

Could you try to run your app in Xcode? It seems like the Fleet issue: https://youtrack.jetbrains.com/issues/FL

terrakok avatar Jun 05 '24 07:06 terrakok

If it's not then provide a reproducer, please.

terrakok avatar Jun 05 '24 07:06 terrakok

I have the same log after adding Room to the project. It looks like an informational log so i'm just ignoring it. This doesn't seem to be a Compose problem. And i use Android Studio so this is not a Fleet issue too

alexzhirkevich avatar Jun 05 '24 08:06 alexzhirkevich

I have the same error with Room configuration, and I solved with:

kotlin{
    sourceSets.iosMain {
        kotlin.srcDir("build/generated/ksp/metadata")
    }
    ...
}

// Room configuration to generate metadata files
room {
    schemaDirectory("$projectDir/schemas")
}

dependencies {
    add("kspCommonMainMetadata", libs.room.compiler)
    add("kspAndroid", libs.room.compiler)
}

tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().configureEach {
    if (name != "kspCommonMainKotlinMetadata") {
       dependsOn("kspCommonMainKotlinMetadata")
    }
}

tairoroberto avatar Jun 05 '24 21:06 tairoroberto

I'm seeing this as well. This is what I see:

Failed to load native library:libjansi.jnilib. The native library file at /Users/sterling/.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: /Users/sterling/.gradle/native/jansi/1.18/osx/libjansi.jnilib: dlopen(/Users/sterling/.gradle/native/jansi/1.18/osx/libjansi.jnilib, 0x0001): tried: '/Users/sterling/.gradle/native/jansi/1.18/osx/libjansi.jnilib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/sterling/.gradle/native/jansi/1.18/osx/libjansi.jnilib' (no such file), '/Users/sterling/.gradle/native/jansi/1.18/osx/libjansi.jnilib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

I've got ktor and Room in my project but not sure it's related to them. I tried to add the solution above to my project but no change. I haven't see this in my other projects. It doesn't seem to block me from building or running my project. I'm using an M1 mac.

fluxxion82 avatar Jun 13 '24 18:06 fluxxion82

I've got Room and Kotlin2 in my project. (Kotlin 1.9.24 is ok) https://github.com/JetBrains/compose-multiplatform/issues/4928#issuecomment-2166540240

taetae98coding avatar Jun 14 '24 15:06 taetae98coding

I've got Room and Kotlin2 in my project. (Kotlin 1.9.24 is ok) #4928 (comment)

ok yeah i have the same...I thought maybe I started to see it when I added Room. haven't tried 1.9.24 but I can probably try that out to check what happens.

fluxxion82 avatar Jun 15 '24 02:06 fluxxion82

Im also having the same problem. Room is my only dependency. I cannot find a good example of how to add the dependency to a project that has been created with the KMM wizard, so I might have done something wrong.

Mikkelet avatar Jun 15 '24 21:06 Mikkelet

I've reported the same issue for Kotlin without Compose + a link to a reproducer https://youtrack.jetbrains.com/issue/KT-69523

art-shen avatar Jul 01 '24 09:07 art-shen

As I see the problem is Room specific, and the compose multiplatform is not the reason

terrakok avatar Jul 01 '24 10:07 terrakok

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

okushnikov avatar Jul 14 '24 14:07 okushnikov

I have the same error with Room configuration, and I solved with:

kotlin{
    sourceSets.iosMain {
        kotlin.srcDir("build/generated/ksp/metadata")
    }
    ...
}
// Room configuration to generate metadata files
room {
    schemaDirectory("$projectDir/schemas")
}

dependencies {
    add("kspCommonMainMetadata", libs.room.compiler)
    add("kspAndroid", libs.room.compiler)
}

tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().configureEach {
    if (name != "kspCommonMainKotlinMetadata") {
       dependsOn("kspCommonMainKotlinMetadata")
    }
}

worked like a charm

harshagrawal6763 avatar Jul 24 '24 19:07 harshagrawal6763