How do I know which kotlin used?

Hi,
I’m disrupted with kotlin version installed.

first version with a bug ki-shell 0.5.2 and :

C:\Users\Laurent>kotlinc -version
info: kotlinc-jvm 1.5.30-release-408 (JRE 18.0.1.1+2-6)

C:\Users\Laurent>java --version
java 18.0.1.1 2022-04-22
Java(TM) SE Runtime Environment (build 18.0.1.1+2-6)
Java HotSpot(TM) 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)

C:\Users\Laurent>C:\Users\Laurent\Desktop\ki\bin\ki.bat -version
java version "18.0.1.1" 2022-04-22
Java(TM) SE Runtime Environment (build 18.0.1.1+2-6)
Java HotSpot(TM) 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)

C:\Users\Laurent>C:\Users\Laurent\Desktop\ki\bin\ki.bat
ki-shell 0.5.2/1.7.0
type :h for help
[0] var x: String?=null
[1] x = readln()
[2] x?.length
res2: Int = 7
[3] x
res3: String = 123456
[4]

Second version installed (android canary)

F:\android-studio-canary\android-studio\plugins\Kotlin\kotlinc\bin>kotlinc -version
info: kotlinc-jvm 1.7.0-release-for-android-studio (JRE 18.0.1.1+2-6)

F:\android-studio-canary\android-studio\plugins\Kotlin\kotlinc\bin>java -version
java version "18.0.1.1" 2022-04-22
Java(TM) SE Runtime Environment (build 18.0.1.1+2-6)
Java HotSpot(TM) 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)

F:\android-studio-canary\android-studio\plugins\Kotlin\kotlinc\bin>kotlinc
Welcome to Kotlin version 1.7.0-release-for-android-studio (JRE 18.0.1.1+2-6)
Type :help for help, :quit for quit
>>> var x: String?=null
>>> x = readln()
x = readln()123456
>>> x?.length
res2: kotlin.Int? = 6
>>>

With python when I run a script in python console or when I run script from system console results are always equals
Here 1.7.0 in ki-shell is not Kotlin version 1.7.0 in kotlinc. It’s very disturbing

How do you manage this to ensure that ki-shell and kotlinc are identical?

I’m not entirely sure what do you ask. You can have multiple versions of the Kotlin compiler, it really depends on your local setup.

in ki-shell it’s version 1.7.0 and in kotlinc it’s version 1.7.0 but results are different

Another question in kotlinc I can use it as ki-shell why two versions?

KI and kotlinc are just two different implementations of REPL for Kotlin. I don’t know what is the reason for a 6 vs 7 difference. It looks like KI intercepted some whitespace char like space or a new line at the end of the string. This is probably not related to your code or Kotlin per se, but rather to how REPL handles the terminal input.

1 Like

You can check stdlib version with KotlinVersion.CURRENT. But otherwise @broot is correct.

1 Like

I check in ki-sh

[

0] KotlinVersion.CURRENT
res0: KotlinVersion = 1.7.0

and in kotlinc

>>> KotlinVersion.CURRENT
res2: kotlin.KotlinVersion = 1.7.0