Unable to launch Kotlin REPL: CommandLineWrapper is ill-suited for launching apps
Asked Answered
P

5

40

I'm trying to use the Kotlin REPL within Android Studio.
However, when I open it, I get the following output:

"E:\Program Files\Android\Arctic Fox\android-studio\jre\bin\java.exe" -Dkotlin.repl.ideMode=true -Dfile.encoding=UTF-8 -classpath "E:\Program Files\Android\Arctic Fox\android-studio\lib\idea_rt.jar;C:\Users\me\AppData\Local\Temp\classpath901685403.jar" com.intellij.rt.execution.CommandLineWrapper C:\Users\me\AppData\Local\Temp\classpath901685403.jar org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
`CommandLineWrapper` is ill-suited for launching apps on Java 9+.
If the run configuration uses "classpath file", please change it to "@argfile".
Otherwise, please contact support.

Process finished with exit code 1

The closest solution I've been able to find is this one:
Test framework quit unexpectedly - ClassNotFound Exception
which suggests changing a value in the run configuration, however there doesn't seem to be a run configuration avalible for the REPL.

There is one for "Java Scratch", however changing this does not solve the issue.

I'm using the Arctic Fox Beta (2020.3.1 Beta 5), with version 203-1.5.20-release-289-AS7717.8 of the Kotlin plugin.

Phocis answered 12/7, 2021 at 18:49 Comment(2)
I have the same issue, for some reason if i start REPL again after it failed (without closing the failed REPL), it now asks for a context module and works. If I open it again, it works. If I close it, then open it again, it fails.Quechua
comment from @Quechua is the only way for me to get the repl to work. IntelliJ IDEA 2022.3.2 (Community Edition)Craner
A
55

Keeping the REPL window displaying the above error, again select Tools > Kotlin > Kotlin REPL

A choice is displayed with two items (Project) (Project).app

Select the first option with the name of your project and the REPL starts working.

error message

option after selecting Kotlin REPL again

correctly running REPL

Artima answered 27/10, 2021 at 3:42 Comment(2)
this worked for me with Android Studio Bumblebee | 2021.1.1 Patch 2 Build #AI-211.7628.21.2111.8193401, built on February 17, 2022Conferral
Worked on Android Studio Dolphin | 2021.3.1 as wellMyelitis
P
18

I changed Run > Edit Configurations... > Templates > Java Scratch > Shorten command line to @argfile (Java 9+) and it fixes the issue.

Android Studio Arctic Fox | 2020.3.1 Build #AI-203.7717.56.2031.7583922, built on July 26, 2021 Runtime version: 11.0.10+0-b96-7249189 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

Pretzel answered 15/9, 2021 at 6:51 Comment(4)
This doesn't work for me. I have Android Studio Arctic Fox 2020.3.1 Patch 3.Moramorabito
Worked for me in Bumblebee 2021.1.1: Run>Edit Configurations...>Edit configuration templates...>Java Scratch>Shorten command line:>@argfile (Java 9+)Aplanospore
If the steps mentioned in the answer don't work then in the Java Scratch file look for classPath Module and click one of the modules( YOUPROJECTNAME, YOURPROJECTNAME.APP) and then select the @argfile(Java9+) shorten command line for that module . And when you open the REPL choose the module which you selected before when changed its short command linePanga
I really hoped that this work for me, but it didn't unfortunately: /usr/lib/jvm/java-11-openjdk-amd64/bin/java -Dkotlin.repl.ideMode=true -Dfile.encoding=UTF-8 -classpath /home/xxx/android-studio/lib/idea_rt.jar:/tmp/classpath1056675736.jar com.intellij.rt.execution.CommandLineWrapper /tmp/classpath1056675736.jar org.jetbrains.kotlin.cli.jvm.K2JVMCompiler CommandLineWrapper is ill-suited for launching apps on Java 9+. If the run configuration uses "classpath file", please change it to "@argfile". Otherwise, please contact support.Craner
T
2

A temporary solution could be if you add the following expression to your gradle.properties file:

android.enableBuildCache=false

After that, Gradle sync (and maybe restarting your IDE) is needed of course.

Tightwad answered 31/3, 2022 at 11:24 Comment(0)
T
1

You have to select the right java module(app or if you have any other) from the project directory. If you select any specific class or package inside your java module(say app module) it will give error.

Another way Select Gradle scripts option in Project Manager and then go to Tools > Kotlin > Kotlin REPL. A Choose context module pop up will open. Select the scope of your REPL here Choose Context Module

Trottier answered 19/1, 2024 at 8:16 Comment(0)
M
0

I have the same error but eventually fixed it by invalidate caches / restart. Btw I'm using Android Studio Arctic Fox | 2020.3.1 RC 1 and Kotlin plugin version 203-1.5.20-release-289-AS7717.8

Mule answered 28/7, 2021 at 7:31 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.