Task compileKotlin2Js Fails In Gradle 4.4: Kotlin home does not exist or is not a directory

After updating Gradle to 4.4 and running ./gradlew build the build fails with the following error:

:compileJava NO-SOURCE
e: Kotlin home does not exist or is not a directory: 
:compileKotlin2Js FAILED

There is a KOTLIN_HOME environment variable which is correctly set in the system.

1 Like

Issue still persists after emptying the cache and restarting IntelliJ.

Tried setting kotlinHome in the build.gradle.kts file:

// ...
buildscript {
    // ...
}

val kotlinHome = file("~/.sdkman/candidates/kotlin/1.2.0")

Unfortunately that doesn’t resolve the issue.

1 Like

Very weird. Found a temporary workaround:

  1. Change the Kotlin version to 1.1.61 in the build.gradle.kts file
  2. Do a Gradle refresh in IntelliJ
  3. Run the following in the terminal: ./gradlew build
  4. Revert the Kotlin version back to 1.2.0 in the build file
  5. Do another Gradle refresh
  6. Run the following in the terminal: ./gradlew build
1 Like

Same issue. I’m working with KotlinJVM:

e: Kotlin home does not exist or is not a directory:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
1 actionable task: 1 executed

Few miniutes ago it’s fine. I didn’t change anything and it raises this error now.

My solution: kill the gradle process (named “java". Don’t kill IntelliJ :wink:), and after gradle restart it’s fine.

Yep, sadly this solves the issue:

killall java
./gradlew clean assemble