Cannot read externs.js when compiling kotlin-stdlib-js


#1

I’m trying to add a new feature into the js section and I just made a test function:

public fun String.testBuild() : String {
return “Hello Build”
}

at the bottom of stringsCode.kt but when I try and do ./gradlew build install in the libraries directory I am getting this error:

:kotlin-stdlib-js:compileBuiltinsKotlin2Js UP-TO-DATE
:kotlin-stdlib-js:prepareBuiltinsSources UP-TO-DATE
:kotlin-stdlib-js:preprocessSourcesMain UP-TO-DATE
:kotlin-stdlib-js:compileKotlin2Js
[KOTLIN] Received unexpected message from compiler daemon: category=0, severity=2, message=‘kotlinc-js @snapshot@ (JRE 1.8.0_25-b17)’, attachment=null
w: /Users/joshpinkney/Documents/kotlin/js/js.libraries/src/core/builtins.kt: (111, 27): Parameter ‘baseClass’ is never used
w: /Users/joshpinkney/Documents/kotlin/js/js.libraries/src/core/collections/ArrayList.kt: (44, 39): Unchecked cast: Any? to E
w: /Users/joshpinkney/Documents/kotlin/js/js.libraries/src/core/collections/ArrayList.kt: (47, 16): Unchecked cast: Any? to E
w: /Users/joshpinkney/Documents/kotlin/js/js.libraries/src/core/text.kt: (38, 30): The corresponding parameter in the supertype ‘CharSequence’ is named ‘startIndex’. This may cause problems when calling this function with named arguments.
w: /Users/joshpinkney/Documents/kotlin/js/js.libraries/src/core/text.kt: (38, 42): The corresponding parameter in the supertype ‘CharSequence’ is named ‘endIndex’. This may cause problems when calling this function with named arguments.
w: /Users/joshpinkney/Documents/kotlin/js/js.libraries/src/dom/EventListener.kt: (22, 37): The corresponding parameter in the supertype ‘EventListener’ is named ‘event’. This may cause problems when calling this function with named arguments.
w: /Users/joshpinkney/Documents/kotlin/js/js.libraries/src/reflect/reflection.kt: (25, 87): ‘jsClass: JsClass’ is deprecated. Use class literal and extension property js instead.
w: /Users/joshpinkney/Documents/kotlin/libraries/stdlib/js/build/builtin-sources/Collections.kt: (324, 16): Unchecked cast: Nothing? to V
w: /Users/joshpinkney/Documents/kotlin/libraries/stdlib/js/build/common-sources/text/Strings.kt: (1099, 63): Name shadowed: startIndex
w: /Users/joshpinkney/Documents/kotlin/libraries/stdlib/js/build/common-sources/text/Strings.kt: (1121, 63): Name shadowed: startIndex
:kotlin-stdlib-js:compileJs
[ant:closureCompiler] ERROR - Cannot read: …/…/…/…/Documents/kotlin/js/js.libraries/src/js/externs.js
[ant:closureCompiler] 1 error(s), 0 warning(s)
:kotlin-stdlib-js:compileJs FAILED

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘/Users/joshpinkney/Documents/kotlin/libraries/stdlib/js/build.gradle’ line: 151

  • What went wrong:
    Execution failed for task ‘:kotlin-stdlib-js:compileJs’.

Compilation failed.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 31.503 secs


#2

I had the same problem once and deleting the ~/.gradle directory helped me.