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

ScriptREPL: CLI arg to disable verbose #451

Open
jayvdb opened this issue Feb 11, 2023 · 5 comments
Open

ScriptREPL: CLI arg to disable verbose #451

jayvdb opened this issue Feb 11, 2023 · 5 comments

Comments

@jayvdb
Copy link

jayvdb commented Feb 11, 2023

I would like to use ScriptREPL to invoke a Kotlin script, and it works when run like so:

jgo --repository scijava.public=https://maven.scijava.org/content/groups/public org.scijava:scijava-common:@ScriptREPL+org.scijava:scripting-kotlin Foo.kt

however I end up with a header of

Welcome to the SciJava REPL!

followed by the "help()"

Available built-in commands:

:help | this handy list of commands
..

Can we add a CLI arg like "quiet", or a different Main-Class, which doesnt emit this before running the script?

@ctrueden
Copy link
Member

ctrueden commented Feb 15, 2023

@jayvdb Good idea to have a CLI entry point for SciJava scripts, which can be used from jgo.

I coded something up: bdd6b1a

You can try it via:

jgo --repository scijava.public=https://maven.scijava.org/content/groups/public org.scijava:scijava-common:2.90.3-SNAPSHOT:@ScriptCLI+org.scijava:scripting-kotlin -o -r Foo.kt

You may want to omit the -o and/or -r flags depending on what sorts of output you desire from the Foo.kt script execution. (Are you using SciJava #@ script parameters?)

I tested the following example:

$ cat hello.groovy
#@ String name
#@ int age
#@output String greeting

greeting = "Hello, ${name}, who is ${age} years old!"
$ jgo org.scijava:scijava-common:2.90.3-SNAPSHOT:@ScriptCLI+org.scijava:scripting-groovy:0.4.2 -o hello.groovy name=Curtis age=5
greeting = Hello, Curtis, who is 5 years old!

P.S. I saw your other recent issues filed in the jgo repo, and would like to help there as well, but will not have time immediately for some days due to other urgent commitments.

@jayvdb
Copy link
Author

jayvdb commented Feb 15, 2023

Thanks.

(Are you using SciJava #@ script parameters?)

No. py2many outputs pure code in various languages, e.g. for the inputs found at https://github.com/py2many/py2many/tree/main/tests/cases the generated outputs you can see in https://github.com/py2many/py2many/tree/main/tests/expected . In order to get nice output, we run the generated output through per language formatters, and py2many/py2many#539 is hoping to use jgo to run those formatters . To test the generated outputs, we use various runners to compare the stdout vs the stdout of the Python original, and in a subsequent PR I would like to use jgo as the Kotlin runner instead of using kscript directly.

@jayvdb
Copy link
Author

jayvdb commented Feb 18, 2023

Thanks. I did a quick test, but dont have a kotlin/kotlinc locally and it didn't work with an error. I'm not sure where the problem exists, so I dumped that in scijava/scripting-kotlin#10 .

I will need to recheck (should be sometime this weekend), but I dont recall having this problem with ScriptREPL so it may be that ScriptCLI isnt doing some step that ScriptREPL is doing.

@jayvdb
Copy link
Author

jayvdb commented Dec 30, 2023

I get the following if I dont have a kotlin/kotlinc handy

> jgo --log-level=DEBUG --repository scijava.public=https://maven.scijava.org/content/groups/public org.scijava:scijava-common:@ScriptCLI+org.scijava:scripting-kotlin -o -r tests/expected/fib.kt 
DEBUG 2023-12-30 20:00:16,518: Using settings:     {'m2repo': '/home/jayvdb/.m2/repository', 'cachedir': '/home/jayvdb/.jgo', 'links': 'auto'}
DEBUG 2023-12-30 20:00:16,518: Using repositories: {'scijava.public': 'https://maven.scijava.org/content/groups/public'}
DEBUG 2023-12-30 20:00:16,518: Using shortcuts:    {}
DEBUG 2023-12-30 20:00:16,518: Returning expanded coordinate org.scijava:scijava-common:@ScriptCLI.
DEBUG 2023-12-30 20:00:16,518: Returning expanded coordinate org.scijava:scripting-kotlin.
INFO 2023-12-30 20:00:16,518: First time start-up may be slow. Downloaded dependencies will be cached for shorter start-up times in subsequent executions.
DEBUG 2023-12-30 20:00:16,518: Executing: ('/usr/bin/mvn', '-B', '-f', '/home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/pom.xml', 'dependency:resolve')
DEBUG 2023-12-30 20:00:24,504: Relevant mvn output: [INFO]    org.scijava:scijava-common:jar:2.97.1:compile -- module org.scijava [auto]
DEBUG 2023-12-30 20:00:24,504: Linking source /home/jayvdb/.m2/repository/org/scijava/scijava-common/2.97.1/scijava-common-2.97.1.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/scijava-common-2.97.1.jar with link_type auto
DEBUG 2023-12-30 20:00:24,504: Linking source /home/jayvdb/.m2/repository/org/scijava/scijava-common/2.97.1/scijava-common-2.97.1.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/scijava-common-2.97.1.jar with link_type hard
DEBUG 2023-12-30 20:00:24,504: Relevant mvn output: [INFO]    org.scijava:parsington:jar:3.1.0:compile -- module org.scijava.parsington [auto]
DEBUG 2023-12-30 20:00:24,504: Linking source /home/jayvdb/.m2/repository/org/scijava/parsington/3.1.0/parsington-3.1.0.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/parsington-3.1.0.jar with link_type auto
DEBUG 2023-12-30 20:00:24,504: Linking source /home/jayvdb/.m2/repository/org/scijava/parsington/3.1.0/parsington-3.1.0.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/parsington-3.1.0.jar with link_type hard
DEBUG 2023-12-30 20:00:24,504: Relevant mvn output: [INFO]    org.scijava:scripting-kotlin:jar:0.2.1:compile -- module org.scijava.plugins.scripting.kotlin [auto]
DEBUG 2023-12-30 20:00:24,504: Linking source /home/jayvdb/.m2/repository/org/scijava/scripting-kotlin/0.2.1/scripting-kotlin-0.2.1.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/scripting-kotlin-0.2.1.jar with link_type auto
DEBUG 2023-12-30 20:00:24,504: Linking source /home/jayvdb/.m2/repository/org/scijava/scripting-kotlin/0.2.1/scripting-kotlin-0.2.1.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/scripting-kotlin-0.2.1.jar with link_type hard
DEBUG 2023-12-30 20:00:24,505: Relevant mvn output: [INFO]    org.jetbrains.kotlin:kotlin-compiler-embeddable:jar:1.4.21:compile -- module kotlin.compiler.embeddable (auto)
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.4.21/kotlin-compiler-embeddable-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-compiler-embeddable-1.4.21.jar with link_type auto
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.4.21/kotlin-compiler-embeddable-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-compiler-embeddable-1.4.21.jar with link_type hard
DEBUG 2023-12-30 20:00:24,505: Relevant mvn output: [INFO]    org.jetbrains.kotlin:kotlin-script-runtime:jar:1.4.21:runtime -- module kotlin.script.runtime (auto)
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-script-runtime/1.4.21/kotlin-script-runtime-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-script-runtime-1.4.21.jar with link_type auto
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-script-runtime/1.4.21/kotlin-script-runtime-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-script-runtime-1.4.21.jar with link_type hard
DEBUG 2023-12-30 20:00:24,505: Relevant mvn output: [INFO]    org.jetbrains.kotlin:kotlin-reflect:jar:1.4.21:runtime -- module kotlin.reflect
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-reflect/1.4.21/kotlin-reflect-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-reflect-1.4.21.jar with link_type auto
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-reflect/1.4.21/kotlin-reflect-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-reflect-1.4.21.jar with link_type hard
DEBUG 2023-12-30 20:00:24,505: Relevant mvn output: [INFO]    org.jetbrains.kotlin:kotlin-daemon-embeddable:jar:1.4.21:runtime -- module kotlin.daemon.embeddable (auto)
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-daemon-embeddable/1.4.21/kotlin-daemon-embeddable-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-daemon-embeddable-1.4.21.jar with link_type auto
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-daemon-embeddable/1.4.21/kotlin-daemon-embeddable-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-daemon-embeddable-1.4.21.jar with link_type hard
DEBUG 2023-12-30 20:00:24,505: Relevant mvn output: [INFO]    org.jetbrains.intellij.deps:trove4j:jar:1.0.20181211:runtime -- module trove4j (auto)
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/intellij/deps/trove4j/1.0.20181211/trove4j-1.0.20181211.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/trove4j-1.0.20181211.jar with link_type auto
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/intellij/deps/trove4j/1.0.20181211/trove4j-1.0.20181211.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/trove4j-1.0.20181211.jar with link_type hard
DEBUG 2023-12-30 20:00:24,505: Relevant mvn output: [INFO]    org.jetbrains.kotlin:kotlin-stdlib:jar:1.4.21:compile -- module kotlin.stdlib
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.4.21/kotlin-stdlib-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-stdlib-1.4.21.jar with link_type auto
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.4.21/kotlin-stdlib-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-stdlib-1.4.21.jar with link_type hard
DEBUG 2023-12-30 20:00:24,505: Relevant mvn output: [INFO]    org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.4.21:compile -- module kotlin.stdlib.common (auto)
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.4.21/kotlin-stdlib-common-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-stdlib-common-1.4.21.jar with link_type auto
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.4.21/kotlin-stdlib-common-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-stdlib-common-1.4.21.jar with link_type hard
DEBUG 2023-12-30 20:00:24,505: Relevant mvn output: [INFO]    org.jetbrains:annotations:jar:13.0:compile -- module annotations (auto)
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/annotations-13.0.jar with link_type auto
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/annotations-13.0.jar with link_type hard
DEBUG 2023-12-30 20:00:24,505: Relevant mvn output: [INFO]    org.jetbrains.kotlin:kotlin-scripting-jsr223:jar:1.4.21:compile -- module kotlin.scripting.jsr223 (auto)
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jsr223/1.4.21/kotlin-scripting-jsr223-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-scripting-jsr223-1.4.21.jar with link_type auto
DEBUG 2023-12-30 20:00:24,505: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jsr223/1.4.21/kotlin-scripting-jsr223-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-scripting-jsr223-1.4.21.jar with link_type hard
DEBUG 2023-12-30 20:00:24,506: Relevant mvn output: [INFO]    org.jetbrains.kotlin:kotlin-scripting-common:jar:1.4.21:runtime -- module kotlin.scripting.common (auto)
DEBUG 2023-12-30 20:00:24,506: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-common/1.4.21/kotlin-scripting-common-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-scripting-common-1.4.21.jar with link_type auto
DEBUG 2023-12-30 20:00:24,506: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-common/1.4.21/kotlin-scripting-common-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-scripting-common-1.4.21.jar with link_type hard
DEBUG 2023-12-30 20:00:24,506: Relevant mvn output: [INFO]    org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:1.3.7:runtime -- module kotlinx.coroutines.core (auto)
DEBUG 2023-12-30 20:00:24,506: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.3.7/kotlinx-coroutines-core-1.3.7.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlinx-coroutines-core-1.3.7.jar with link_type auto
DEBUG 2023-12-30 20:00:24,506: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.3.7/kotlinx-coroutines-core-1.3.7.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlinx-coroutines-core-1.3.7.jar with link_type hard
DEBUG 2023-12-30 20:00:24,506: Relevant mvn output: [INFO]    org.jetbrains.kotlin:kotlin-scripting-jvm:jar:1.4.21:runtime -- module kotlin.scripting.jvm (auto)
DEBUG 2023-12-30 20:00:24,506: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jvm/1.4.21/kotlin-scripting-jvm-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-scripting-jvm-1.4.21.jar with link_type auto
DEBUG 2023-12-30 20:00:24,506: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jvm/1.4.21/kotlin-scripting-jvm-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-scripting-jvm-1.4.21.jar with link_type hard
DEBUG 2023-12-30 20:00:24,506: Relevant mvn output: [INFO]    org.jetbrains.kotlin:kotlin-scripting-jvm-host:jar:1.4.21:runtime -- module kotlin.scripting.jvm.host (auto)
DEBUG 2023-12-30 20:00:24,506: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jvm-host/1.4.21/kotlin-scripting-jvm-host-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-scripting-jvm-host-1.4.21.jar with link_type auto
DEBUG 2023-12-30 20:00:24,506: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jvm-host/1.4.21/kotlin-scripting-jvm-host-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-scripting-jvm-host-1.4.21.jar with link_type hard
DEBUG 2023-12-30 20:00:24,506: Relevant mvn output: [INFO]    org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:jar:1.4.21:runtime -- module kotlin.scripting.compiler.embeddable (auto)
DEBUG 2023-12-30 20:00:24,506: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-compiler-embeddable/1.4.21/kotlin-scripting-compiler-embeddable-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-scripting-compiler-embeddable-1.4.21.jar with link_type auto
DEBUG 2023-12-30 20:00:24,506: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-compiler-embeddable/1.4.21/kotlin-scripting-compiler-embeddable-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-scripting-compiler-embeddable-1.4.21.jar with link_type hard
DEBUG 2023-12-30 20:00:24,506: Relevant mvn output: [INFO]    org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:jar:1.4.21:runtime -- module kotlin.scripting.compiler.impl.embeddable (auto)
DEBUG 2023-12-30 20:00:24,506: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-compiler-impl-embeddable/1.4.21/kotlin-scripting-compiler-impl-embeddable-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-scripting-compiler-impl-embeddable-1.4.21.jar with link_type auto
DEBUG 2023-12-30 20:00:24,506: Linking source /home/jayvdb/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-compiler-impl-embeddable/1.4.21/kotlin-scripting-compiler-impl-embeddable-1.4.21.jar to target /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/kotlin-scripting-compiler-impl-embeddable-1.4.21.jar with link_type hard
DEBUG 2023-12-30 20:00:24,567: class path: /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/*
[ERROR] javax.script.ScriptException: Unable to initialize repl compiler:
  ERROR java.lang.ExceptionInInitializerError: java.lang.ExceptionInInitializerError
	at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.asJsr223EvalResult(KotlinJsr223JvmScriptEngineBase.kt:104)
	at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.compileAndEval(KotlinJsr223JvmScriptEngineBase.kt:63)
	at kotlin.script.experimental.jvmhost.jsr223.KotlinJsr223ScriptEngineImpl.compileAndEval(KotlinJsr223ScriptEngineImpl.kt:94)
	at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.eval(KotlinJsr223JvmScriptEngineBase.kt:31)
	at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:262)
	at org.scijava.plugins.scripting.kotlin.KotlinScriptLanguage$SynchronizedScriptEngine.eval(KotlinScriptLanguage.kt:70)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:173)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:125)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:64)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:247)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
result = null
null

and now I also cant get the REPL working if I dont have a kotlin/kotlinc handy.

> jgo --log-level=DEBUG --repository scijava.public=https://maven.scijava.org/content/groups/public org.scijava:scijava-common:@ScriptREPL+org.scijava:scripting-kotlin < tests/expected/fib.kt 
DEBUG 2023-12-30 20:04:45,423: Using settings:     {'m2repo': '/home/jayvdb/.m2/repository', 'cachedir': '/home/jayvdb/.jgo', 'links': 'auto'}
DEBUG 2023-12-30 20:04:45,423: Using repositories: {'scijava.public': 'https://maven.scijava.org/content/groups/public'}
DEBUG 2023-12-30 20:04:45,423: Using shortcuts:    {}
DEBUG 2023-12-30 20:04:45,423: Returning expanded coordinate org.scijava:scijava-common:@ScriptREPL.
DEBUG 2023-12-30 20:04:45,423: Returning expanded coordinate org.scijava:scripting-kotlin.
DEBUG 2023-12-30 20:04:45,423: class path: /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/83e3837a9a96373ac912ce5864057e9dfc0de195c47c1f6bd0db59eb4968c808/*
Welcome to the SciJava REPL!

Available built-in commands:

  :help           | this handy list of commands
  :vars           | dump a list of variables
  :lang <name>    | switch the active language
  :langs          | list available languages
  :debug          | toggle full stack traces
  :quit           | exit the REPL

Or type a statement to evaluate it with the active language.

Have fun!

> Unable to initialize repl compiler:
  ERROR java.lang.ExceptionInInitializerError: java.lang.ExceptionInInitializerError
> Unable to initialize repl compiler:
  ERROR Could not initialize class org.jetbrains.kotlin.com.intellij.pom.java.LanguageLevel: java.lang.NoClassDefFoundError: Could not initialize class org.jetbrains.kotlin.com.intellij.pom.java.LanguageLevel
...

Even with kotlin/kotlinc and KOTLIN_HOME set, I still see those same errors.

Seems like I may need to manually add some extra jars. Perhaps https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-gradle-plugin

@jayvdb
Copy link
Author

jayvdb commented Dec 30, 2023

I can get the CLI working with

> jgo --log-level=DEBUG --repository scijava.public=https://maven.scijava.org/content/groups/public --additional-endpoints org.jetbrains.kotlin:kotlin-scripting-jvm-host org.jetbrains.kotlin:kotlin-stdlib org.scijava:scijava-common:@ScriptCLI+org.scijava:scripting-kotlin -o tests/expected/print.kt 
DEBUG 2023-12-30 21:08:06,242: Using settings:     {'m2repo': '/home/jayvdb/.m2/repository', 'cachedir': '/home/jayvdb/.jgo', 'links': 'auto'}
DEBUG 2023-12-30 21:08:06,242: Using repositories: {'scijava.public': 'https://maven.scijava.org/content/groups/public'}
DEBUG 2023-12-30 21:08:06,242: Using shortcuts:    {}
DEBUG 2023-12-30 21:08:06,242: Returning expanded coordinate org.scijava:scijava-common:@ScriptCLI.
DEBUG 2023-12-30 21:08:06,242: Returning expanded coordinate org.jetbrains.kotlin:kotlin-scripting-jvm-host.
DEBUG 2023-12-30 21:08:06,243: Returning expanded coordinate org.scijava:scripting-kotlin.
DEBUG 2023-12-30 21:08:06,243: class path: /home/jayvdb/.jgo/org.scijava/scijava-common/RELEASE/cc893ffa58d25c93e9ba7ea6eeea7e5135e868ef5cc70021f7c891b6c3cecf72/*
result = null

However nothing is emitted.

tests/expected/print.kt is

fun show() {
    println("b")
    println("2 b")
    var a: Double = 2.1
    println("$a")
    val b = 2.1
    println("$b")
    val c = true
    if (true) {
        val __tmp1 = if (c) "True" else "False"
        println("$__tmp1")
    }
}

fun main(argv: Array<String>) {
    show()
}

I guess it isnt calling main.

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

2 participants