Skip to content

Does not work with Kotlin 1.9.0 #408

Closed

Description

@dalewking

Trying kscript for the first time and installed kotlin and kscript with sdkman on Mac and simple execution fails:

% kscript 'println("hello world")'
Exception in thread "main" java.lang.ClassNotFoundException: kscript.scriplet.Scriplet
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        at Main_Scriplet$Companion.main(Main_Scriplet.kt:5)
        at Main_Scriplet.main(Main_Scriplet.kt)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.jetbrains.kotlin.runner.AbstractRunner.run(runners.kt:70)
        at org.jetbrains.kotlin.runner.Main.run(Main.kt:188)
        at org.jetbrains.kotlin.runner.Main.main(Main.kt:198)
[kscript] [ERROR] Execution of scriplet failed:
[kscript] [ERROR] Command     : 'bash -c /Users/dalewking/.sdkman/candidates/kotlin/1.8.20/bin/kotlin  -classpath '/Users/dalewking/Library/Caches/kscript/jar_7a6cdcc8b547b2bb2a0ad2ab4f24c291/scriplet.jar:/Users/dalewking/.sdkman/candidates/kotlin/1.8.20/lib/kotlin-script-runtime.jar' Main_Scriplet '
[kscript] [ERROR] Exit Code   : 1   
[kscript] [ERROR] 

Tried with Kotlin 1.9.0 and 1.8.20 since I thought new kotlin version may have been the issue

Activity

  1. dalewking commented on Jul 8, 2023

    @dalewking
    Author

    I tried to re-invoke with -d argument to get more info and now it works

  2. dalewking commented on Jul 8, 2023

    @dalewking
    Author

    Actually it may have been that I also tried a kscript -c to get it working

  3. dalewking commented on Jul 8, 2023

    @dalewking
    Author

    OK the issue is that it isn't working with Kotlin 1.9. Switching to Kotlin 1.8.20 allows it to work, but it is necessary to clear the cache after switching versions.

  4. changed the title [-]Fresh install not working on Mac[/-] [+]Does not work with Kotlin 1.9.0[/+] on Jul 8, 2023
  5. cgruber commented on Jul 11, 2023

    @cgruber

    Same thing here. We just upgraded our cli tools to 1.9 and kscript dies on the same error.

  6. aartiPl commented on Jul 12, 2023

    @aartiPl
    Collaborator

    I will have a look at it.

  7. iamironz commented on Jul 13, 2023

    @iamironz

    Same here.

    Exception in thread "main" java.lang.ClassNotFoundException: kscript.scriplet.Android_lint
    	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:476)
    	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
    	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    	at Main_Android_lint$Companion.main(Main_Android_lint.kt:5)
    	at Main_Android_lint.main(Main_Android_lint.kt)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    	at org.jetbrains.kotlin.runner.AbstractRunner.run(runners.kt:70)
    	at org.jetbrains.kotlin.runner.Main.run(Main.kt:188)
    	at org.jetbrains.kotlin.runner.Main.main(Main.kt:198)
    

    We've updated Kotlin version up to 1.9.0 on developer machines and all the scripts got broken, as a result, all local script calls crashed.
    Fortunately, on CI it still works as the Docker container has pinned runtime versions.
    If you need any help - don't hesitate to ask, as we are heavily relying on kscript in our project to reproduce CI steps locally we consider this issue critical.

  8. aartiPl commented on Jul 13, 2023

    @aartiPl
    Collaborator

    I am working on this. The root cause seems to be that Kotlin 1.9 disallows .kts files in the source roots.
    Anyway, I recommend pinning the Kotlin version on CI/CD - fixing bugs quickly won't always be possible.

  9. iamironz commented on Jul 14, 2023

    @iamironz

    Thank you.
    Very much appreciated your effort there.

  10. aartiPl commented on Jul 14, 2023

    @aartiPl
    Collaborator

    I have just released kscript 4.2.3-RC.1
    Please check if everything works as expected in your code - there are changes in the core engine of kscript, so I would like to ensure that nothing is broken after fixing the problem.

    sdk install kscript 4.2.3-RC.1
    
  11. self-assigned this
    on Jul 19, 2023
  12. aartiPl commented on Jul 19, 2023

    @aartiPl
    Collaborator

    @cgruber , @dalewking , @iamironz - can you confirm that the issue is fixed?

  13. iamironz commented on Jul 19, 2023

    @iamironz

    Works fine for me, thank you so much!

  14. aartiPl commented on Jul 22, 2023

    @aartiPl
    Collaborator

    The final resolution is even simpler, without changing much in the kscript core.
    I have just released kscript 4.2.3 with Kotlin 1.9.0 compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions