Can anyone help me? I’m on a Macbook so I end up u...
# compiler
r
Can anyone help me? I’m on a Macbook so I end up using z-shell but the problem still occurs when I use bash. I’m trying to run Kotlin/Native using the command-line compiler but I get an error saying kotlin-native command cannot be found. I’ve installed the compiler but still get the error.
e
Can you please post exactly the command you are running and the error you are getting?
r
Copy code
kotlinc-native hello.kt -o hello
I’m following this page: Write "Hello Kotlin/Native" program The error I’m getting is 
zsh: command not found: kotlinc-native
This is my kotlin version: 
Kotlin version 1.6.10-release-923 (JRE 16.0.2+7)
e
Install the compiler by unpacking its archive to a directory of your choice and adding the path to its
/bin
directory to the
PATH
environment variable.
The error message suggests you didn’t do this correctly
you can check your path by doing
echo $PATH
.
which kotlinc-native
should show the path where you put the compiler
1
r
it that all one command?
echo $PATH which kotlinc-native
?
e
Two different commands.
echo $PATH
shows your current PATH env, on which there should be one path to the bin-folder for
kotlinc-native
r
This is my result:
/Library/Frameworks/Python.framework/Versions/3.9/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
e
and where did you install the compiler?
r
/Users/roshad/Kotlin/kotlinc/bin
Should I use nano and add this to my /etc/paths?
e
add
export PATH=$PATH:/Users/roshad/Kotlin/kotlinc/bin
to the file
/Users/roshad/.zshrc
and restart your terminal and it should be good
when you type commands in your terminal, it will scan every directory defined in the PATH variable for an executable matching what you wrote (
kotlinc-native
in this case, is a file which you added in
/Users/roshad/Kotlin/kotlinc/bin
)
r
Okay done, but when I downloaded the compiler kotlinc-native is not there
This is what the path looks like now
/Library/Frameworks/Python.framework/Versions/3.9/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/roshad/Kotlin/kotlinc/bin:/Users/roshad/Kotlin/kotlinc/bin
e
yeah, you’re right.. seems the native compilers are not part of
kotlin-compiler-$Version.zip
.. try downloading the
kotlin-native-macos
appropriate for your machine (aarch64 for M1 macbooks, x86_64 otherwise) instead
r
Okay done. Do I do the same as before but with the path of the bin folder of kotlin-native?
e
try and see
r
This is the new command I’m trying
export PATH=$PATH:/Users/roshad/Kotlin/kotlin-native/bin
I’m getting this error
I’ve also renamed
kotlin-native-macos-aarch64-1.6.10
to
kotlin-native
in my Kotlin folder.
This is my kotlin-native folder