Hi guys, I’m receiving the following error in my b...
# kotlin-native
g
Hi guys, I’m receiving the following error in my build process.
Copy code
error: compilation failed: Could not find "/Users/travis/build/my_project/application/native/wasm/build/klib/kotlinx.interop.wasm.dom-jsinterop.klib" in [/Users/travis/build/my_project, /Users/travis/.konan/klib, /Users/travis/.konan/kotlin-native-macos-1.1.2/klib/common, /Users/travis/.konan/kotlin-native-macos-1.1.2/klib/platform/wasm32].
But this error is only happening on the CI and not in my development machine. The strange thing is the same error is also happening in appveyor and circleci too. Does someone knows a workaround for this?
s
Have you tried removing
application/native/wasm/build
on your development machine and CI?
o
could you take a look in log few lines before that message, it may say smth about incompatible versions
g
Before these line I have the following:
Copy code
> Task :application:js:vanilla:jsProcessResources
> Task :application:js:vanilla:compileKotlinMetadata NO-SOURCE
> Task :application:js:vanilla:metadataMainClasses UP-TO-DATE
> Task :application:js:vanilla:metadataJar
> Task :application:js:vanilla:jsTestProcessResources NO-SOURCE
> Task :application:native:wasm:jsinterop UP-TO-DATE
> Task :common:compileKotlinNativeAndroidArm32
Downloading native dependencies (LLVM, sysroot etc). This is a one-time action performed only on the first run of the compiler.
> Task :application:native:wasm:compileKotlinWasm32 FAILED
Copy code
* Source files: Example.kt
 * Compiler version info: Konan: 1.1.2 / Kotlin: 1.3.21
 * Output kind: LIBRARY
My module is located at this folder
application/native/wasm
, so I don’t know how to remove this. My build.gradle.kts is the following:
Copy code
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
import java.nio.file.Paths

plugins {
	kotlin("multiplatform")
}

repositories {
	jcenter()
}

val packageName = "kotlinx.interop.wasm.dom"
val jsinteropKlibFileName = Paths.get(buildDir.toString(), "klib", "$packageName-jsinterop.klib").toString()

kotlin {
	wasm32 {
		compilations["main"].outputKinds("EXECUTABLE")
		compilations["main"].entryPoint("com.company.team.project.application.native_.wasm.main")
	}

	sourceSets {
		val wasm32Main by getting {
			kotlin.srcDir("src/main/kotlin")
			resources.srcDir("src/main/resources")

			dependencies {
				implementation(files(jsinteropKlibFileName))
			}
		}
		val wasm32Test by getting {
			kotlin.srcDir("src/test/kotlin")
			resources.srcDir("src/test/resources")

			dependencies {
			}
		}
	}
}

tasks {
	withType<KotlinNativeCompile>().configureEach {
		dependsOn("jsinterop")
	}
}

task("jsinterop") {
	val os = org.gradle.internal.os.OperatingSystem.current()!!
	val workingDir = projectDir
	val ext = if (os.isWindows) ".bat" else ""
	val distributionPath = project.properties["konanHome"] as String
	val jsinteropCommand = Paths.get(file(distributionPath).path, "bin", "jsinterop$ext").toString()

	inputs.property("jsinteropCommand", jsinteropCommand)
	inputs.property("jsinteropPackageName", packageName)
	outputs.file(jsinteropKlibFileName)

	exec {
		commandLine(
			jsinteropCommand,
			"-pkg",
			packageName,
			"-o",
			jsinteropKlibFileName,
			"-target",
			"wasm32"
		)
	}
}
It is working on my local environment =/, very strange, but this is somehow related with the path of the project, I think.