Can't run Kotlin programs on the command line - kotlin

I have downloaded the kotlin compiler 1.2.21 zip file, extracted it to C:\Program files\ and also added the bin folder in the system PATH variable. I had already installed and configured JDK.
I wrote a simple program, saved it in C:\USERS\USER\ with the name args.kts and ran it in cmd with this command : kts args.kts Hello
But I am getting this error every time :
exception: java.lang.ArrayIndexOutOfBoundsException: Index 11052 out of bounds for length 11052
at org.jetbrains.org.objectweb.asm.ClassReader.readUnsignedShort(ClassReader.java:2464)
at org.jetbrains.org.objectweb.asm.ClassReader.readUTF8(ClassReader.java:2525)
at org.jetbrains.org.objectweb.asm.ClassReader.readModule(ClassReader.java:761)
at org.jetbrains.org.objectweb.asm.ClassReader.accept(ClassReader.java:646)
at org.jetbrains.org.objectweb.asm.ClassReader.accept(ClassReader.java:507)
at org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleInfo$Companion.read(JavaModuleInfo.kt:67) at org.jetbrains.kotlin.cli.jvm.modules.CliJavaModuleFinder.findSystemModule(CliJavaModuleFinder.kt:44)
at org.jetbrains.kotlin.cli.jvm.modules.CliJavaModuleFinder.access$findSystemModule(CliJavaModuleFinder.kt:25)
at org.jetbrains.kotlin.cli.jvm.modules.CliJavaModuleFinder$systemModules$1.invoke(CliJavaModuleFinder.kt:37)
at org.jetbrains.kotlin.cli.jvm.modules.CliJavaModuleFinder$systemModules$1.invoke(CliJavaModuleFinder.kt:25) at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:149) at kotlin.sequences.FilteringSequence$iterator$1.calcNext(Sequences.kt:109)
at kotlin.sequences.FilteringSequence$iterator$1.hasNext(Sequences.kt:133)
at kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:254)
at kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:241)
at kotlin.sequences.SequencesKt___SequencesKt.none(_Sequences.kt:1239)
at org.jetbrains.kotlin.cli.jvm.compiler.ClasspathRootsResolver.addModularRoots(ClasspathRootsResolver.kt:227)
at org.jetbrains.kotlin.cli.jvm.compiler.ClasspathRootsResolver.computeRoots(ClasspathRootsResolver.kt:124)
at org.jetbrains.kotlin.cli.jvm.compiler.ClasspathRootsResolver.convertClasspathRoots(ClasspathRootsResolver.kt:79)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:230)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:114)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:409)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:286)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createEnvironmentWithScriptingSupport(K2JVMCompiler.kt:276)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:170)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:63)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:109)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:53)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:92)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:70)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:36)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:157)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:148)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt:343)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.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:567)
at org.jetbrains.kotlin.preloading.Preloader.run(Preloader.java:81)
at org.jetbrains.kotlin.preloading.Preloader.main(Preloader.java:43)
FYI, I followed this site : http://otfried.org/courses/cs109/project-install.html
This is my code inside the args.kts file which was provided in the above mentioned site :
println("Your arguments are:")
for (i in 0 until args.size) {
println("$i: ${args[i]}")
}
Please tell me what to do.

I followed the instructions for the "Manual Install"
at Working with the Command Line Compiler .
If you need the Kotlin REPL, install Kotlin 1.3.31 - 1.3.40 crashes.
Worked perfectly on my Lubuntu 16.04 LTS.
I have no Windows to try it. Sorry.
But it's a tutorial by JetBrains. They should know.
Besides, you can find more of their documentation and tutorials there.
Good luck and happy learning !

I think [Benjamin Charais] (https://stackoverflow.com/users/7729375/benjamin-charais) is right.
There are args.size arguments. So your loop should be:
for (i in 0 until (args.size - 1)) { ...
Sorry, I wasted your time before.

Related

"No single root directory found, all dists must extract to a single directory" error when trying to upload module to zef via App::Mi6

Getting a weird error I've never seen before while trying to upload a new module to zef using the App::Mi6 mi6 release command:
==> Step 9. UploadToZef
Are you sure you want to upload Directory-0.0.1.tar.gz to Zef ecosystem? (y/N) y
Executing /Users/steve/.rakubrew/versions/moar-2022.12/bin/rakudo -e use Fez::CLI --file=Directory-0.0.1.tar.gz upload
>>= Looking in "Directory-0.0.1.tar.gz" for META6.json
=<< No single root directory found, all dists must extract to a single directory
Failed
in method upload at /Users/steve/.rakubrew/versions/moar-2022.12/share/perl6/site/sources/12D2D4FC78FDF40E8B7DEC72AF31ECED31A67D08 (App::Mi6::Fez) line 19
in method run at /Users/steve/.rakubrew/versions/moar-2022.12/share/perl6/site/sources/A4949DB54562D3B5154DD447B5CC2C730F09B0E5 (App::Mi6::Release::UploadToZef) line 24
in method run at /Users/steve/.rakubrew/versions/moar-2022.12/share/perl6/site/sources/BDF7095037EE976677901A8557FD533DCDC6FD65 (App::Mi6::Release) line 49
in method cmd at /Users/steve/.rakubrew/versions/moar-2022.12/share/perl6/site/sources/299DED9746B9228495A0B5E829FE0A6BBD7DFE88 (App::Mi6) line 162
in sub MAIN at /Users/steve/.rakubrew/versions/moar-2022.12/share/perl6/site/resources/5831540356728593B89C55370F0C33F8DD0813F5 line 20
in block <unit> at /Users/steve/.rakubrew/versions/moar-2022.12/share/perl6/site/resources/5831540356728593B89C55370F0C33F8DD0813F5 line 5
in sub MAIN at /Users/steve/.rakubrew/versions/moar-2022.12/share/perl6/site/bin/mi6 line 3
in block <unit> at /Users/steve/.rakubrew/versions/moar-2022.12/share/perl6/site/bin/mi6 line 1
Google turns up nothing on this error. This means I've found a major bug or the three glasses of wine I've had tonight have me doing something really stupid. :)
OK, this is a bug related to how the fez module interacts with how tarballs are generated on a mac.
A pull request has been made to address this issue: https://github.com/tony-o/raku-fez/pull/74.
I'm not sure what accounts for things working on 2022.07 and not 2022.12 version of raku.

Exception::raise(): Unimplemented Parser Node: EmptyElse

When running srb init in a Rails app I get the following:
Generating /tmp/d20220723-3779490-paqj5l/reflection.rbi with 6784 modules and 142 aliases
Printing your code's symbol table into /tmp/d20220723-3779490-paqj5l/from-source.json
/home/allan/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/sorbet-0.5.10206/lib/hidden-definition-finder.rb:123:in `write_constants': Your source can't be read by Sorbet. (RuntimeError)
You can try `find . -type f | xargs -L 1 -t bundle exec srb tc --no-config --isolate-error-code 1000` and hopefully the last file it is processing before it dies is the culprit.
If not, maybe the errors in this file will help: /tmp/d20220723-3779490-paqj5l/from-source.json.err
When I check that error file I find this:
Exception::raise(): Unimplemented Parser Node: EmptyElse
Is there a workaround to get past this error?
Anytime you see Exception::raise in a Sorbet error message, it means there was a bug in Sorbet. You can report Sorbet bugs at https://github.com/sorbet/sorbet/issues
I have created a fix for this bug here: https://github.com/sorbet/sorbet/pull/6161
It will require upgrading Sorbet before you can take advantage of the fix. If you can't wait for that, you will have to hunt down the file in your codebase that uses Ruby's new case ... in syntax for pattern matching with an empty else keyword, and either delete the else keyword or change it to mention else nil instead.
Sorry for the inconvenience.
In the future, please use https://github.com/sorbet/sorbet/issues to report all issues—I only happened to see this by accident today, but I normally do not monitor StackOverflow for bug reports.

In Yocto Dunfell, which recipe is writing out `/lib/systemd/system/getty#.service`

I would like to find the recipe writing out /lib/systemd/system/getty#.service so I can create an append.
First I tried to find out the creating package, which should be systemd:
$ oe-pkgdata-util find-path /lib/systemd/system/getty#.service
systemd: /lib/systemd/system/getty#.service
Thus, I looked up meta/recipes-core/systemd/systemd_244.3.bb (and the systemd.inc), but didn't find anything of value. Only the following line looked like a hit:
RDEPENDS_${PN} += "kmod dbus util-linux-mount util-linux-umount udev (= ${EXTENDPKGV}) util-linux-agetty util-linux-fsck"
This made the impression as if this file might get pulled in as a dependency, and is actually created by util-linux-agetty.
So I looked up the creating recipe:
$ oe-pkgdata-util lookup-recipe util-linux-agetty
util-linux
But in meta/recipes-core/util-linux/util-linux_2.35.1.bb and util-linux.inc I can't find creation of that file either.
I'm genuinely puzzled.
My image is equal to core-image-minimal except that it uses systemd as init manager.

eclipse-neon bower-install can't run due to error in the file

I create javascript project and bower.json. After adding dependencies as follow gives me red-cross on project->bower_components->bootstrap->grunt->change-version.js file and query->src file:
"dependencies":{
"bootstrap":"~3.3.7"
}
This is first problem:
Description Resource Path Location Type
Expected name at 2:1 .eslintrc.json /gruntTest/bower_components/jquery/src line 2 JSON Problem
Second problem:
Description Resource Path Location Type
Unexpected token ILLEGAL change-version.js /gruntTest/bower_components/bootstrap/grunt line 1 JavaScript Problem
I assumed that eclipse neon doesn't need to download Nodeclipse & Enide and try to practice from scratch thats the reason error happened.
Nodeclipse & Enide must installed before practicing nodejs in eclipse.
I followed this link and worked great.
http://www.nodeclipse.org

Objective C, CABase.h file error

I hate Xcode 4! It crashes all the time and finally it gives me an error in CABase.h file which is an library header file that I am not allowed to modify..
I don't even know how this file is broken.
How to fix this problem? It complains like
"Expected *before*
Expected '=',',',';','asm' or '_attribute_' before 'extern'
Also, how can I completely remove Xcode on my Mac and re-install?
You probably just have a simple error, perhaps in a header which is included prior to CABase.h. Use a "divide and conquer" strategy to locate it.
To answer your last question:
$ sudo /Developer/Library/uninstall-devtools –mode=all
This happened to me just because I had the letter 's' at the beginning of one of my implementation files. I must have missed the cmd key when cmd+s for saving the file. Luckily, another compile error discovered this and removing the 's' fixed both errors.
For example,
s//
// GraphingViewController.m