Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when testing JSR223 script when I have Knit as a test dependency #41

Open
aSemy opened this issue Apr 23, 2022 · 0 comments
Open

Comments

@aSemy
Copy link

aSemy commented Apr 23, 2022

  • Kotlin 1.6.21
  • Knit 0.4.0
  • Gradle 7.4.2
  • IntelliJ 2022.1
  • Windows 10

I'm trying to use Knit to test some .kts scripts. I've had lots of problems though, even though the code works when I run it within a main() function.

Here's an example of a script that fails

import java.io.ByteArrayOutputStream
import java.io.PrintStream
import javax.script.ScriptEngineManager
import kotlin.io.path.Path
import kotlin.test.*

    @Test
    fun testBasicEval() {
        val engine = ScriptEngineManager().getEngineByExtension("main.kts")!!
        val res1 = engine.eval("val x = 3")
        assertNull(res1)
        val res2 = engine.eval("x + 2")
        assertEquals(5, res2)
    }

The test is from https://github.com/Kotlin/kotlin-script-examples/tree/master/jvm/jsr223/jsr223-main-kts.

It produces this error whenever I declare Knit as a dependency.

ERROR Unable to initialize repl compiler:
  DEBUG Using JVM IR backend
  ERROR 'void org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl.<init>(org.jetbrains.kotlin.com.intellij.psi.PsiManager)': java.lang.NoSuchMethodError: 'void org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl.<init>(org.jetbrains.kotlin.com.intellij.psi.PsiManager)': java.lang.IllegalStateException: Unable to initialize repl compiler:
  DEBUG Using JVM IR backend
  ERROR 'void org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl.<init>(org.jetbrains.kotlin.com.intellij.psi.PsiManager)': java.lang.NoSuchMethodError: 'void org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl.<init>(org.jetbrains.kotlin.com.intellij.psi.PsiManager)'
javax.script.ScriptException: ERROR Unable to initialize repl compiler:
  DEBUG Using JVM IR backend
  ERROR 'void org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl.<init>(org.jetbrains.kotlin.com.intellij.psi.PsiManager)': java.lang.NoSuchMethodError: 'void org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl.<init>(org.jetbrains.kotlin.com.intellij.psi.PsiManager)': java.lang.IllegalStateException: Unable to initialize repl compiler:
  DEBUG Using JVM IR backend
  ERROR 'void org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl.<init>(org.jetbrains.kotlin.com.intellij.psi.PsiManager)': java.lang.NoSuchMethodError: 'void org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl.<init>(org.jetbrains.kotlin.com.intellij.psi.PsiManager)'

I'm following the example in this repo: https://github.com/Kotlin/kotlin-script-examples/tree/master/jvm/jsr223/jsr223-main-kts

Here's a quick reproduction: https://github.com/asemy/kotlinx-knit/tree/bug/41-jsr223-error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant