1

I tried to build kotlin compiler in Raspberrypi2 on Ubuntu Mate 15.10

When I execute ant -f update_dependencies.xml and during building, error occured below.

override-version:
 [echo] Requested URL https://teamcity.jetbrains.com/guestAuth/app/rest/builds/?locator=buildType:IntelliJMarkdownParser_Build,status:SUCCESS,tag:forKotlin,count:1
 [echo] Build Number: 3174 - Kotlin 1.0.0-beta-5160 Build Id: 662124
  [get] Getting: https://teamcity.jetbrains.com/guestAuth/app/rest/builds/id:662124/artifacts/content/markdown_jar/markdown.jar
  [get] To: /home/kyungkoo/Downloads/kotlin-build-1.0.0-beta-4584/dependencies/markdown.jar
  [get] Not modified - so not downloaded
 [exec] Exception in thread "main" java.lang.reflect.InvocationTargetException
 [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 [exec]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 [exec]     at java.lang.reflect.Method.invoke(Method.java:497)
 [exec]     at org.jetbrains.kotlin.preloading.Preloader.run(Preloader.java:73)
 [exec]     at org.jetbrains.kotlin.preloading.Preloader.main(Preloader.java:35)
 [exec] Caused by: java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no jansi in java.library.path, /tmp/libjansi-32-2155791272664213050.so: /tmp/libjansi-32-2155791272664213050.so: cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)]
 [exec]     at org.fusesource.hawtjni.runtime.Library.doLoad(Library.java:182)
 [exec]     at org.fusesource.hawtjni.runtime.Library.load(Library.java:140)
 [exec]     at org.fusesource.jansi.internal.CLibrary.<clinit>(CLibrary.java:37)
 [exec]     at org.jetbrains.kotlin.cli.common.messages.PlainTextMessageRenderer.<clinit>(PlainTextMessageRenderer.java:35)
 [exec]     at org.jetbrains.kotlin.cli.common.messages.MessageRenderer.<clinit>(MessageRenderer.java:29)
 [exec]     at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:57)
 [exec]     at org.jetbrains.kotlin.cli.common.CLICompiler.doMainNoExit(CLICompiler.java:240)
 [exec]     at org.jetbrains.kotlin.cli.common.CLICompiler.doMain(CLICompiler.java:231)
 [exec]     at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt:246)
 [exec]     at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.kt)
 [exec]     ... 6 more

I installed libjansi-java and libjansi-native-java but it doesn't work. Is any idea solve this problem?


I updated soruce code to build-1.0.0-beta-5569 and added <arg value="-Dkotlin.colors.enabled=false"/> like belows:

--- a/update_dependencies.xml
+++ b/update_dependencies.xml
@@ -368,6 +368,7 @@
     <macrodef name="build-protobuf-java-lite">
         <sequential>
             <exec executable="dependencies/bootstrap-compiler/Kotlin/kotlinc/bin/${kotlinc.executable.path}" failonerror="true">
+                <arg value="-Dkotlin.colors.enabled=false"/>
                 <arg value="-script"/>
                 <arg value="generators/infrastructure/build-protobuf-lite.kts"/>
                 <arg value="${basedir}/ideaSDK/lib/protobuf-2.5.0.jar"/>
@@ -419,6 +420,7 @@
                 <delete dir="${markdown.dir}" failonerror="false"/>
                 <unzip src="dependencies/download/markdown-sources.zip" dest="dependencies"/>
                 <exec executable="dependencies/bootstrap-compiler/Kotlin/kotlinc/bin/${kotlinc.executable.path}" failonerror="true">
+                    <arg value="-Dkotlin.colors.enabled=false"/>
                     <arg value="${markdown.dir}/src"/>
                     <arg value="-d"/>
                     <arg value="${markdown.dir}/out"/>
@@ -874,6 +876,7 @@
             <echo message="URL: ${override.version.url} Version: ${override.version.build.number}"/>

             <exec executable="dependencies/bootstrap-compiler/Kotlin/kotlinc/bin/${kotlinc.executable.path}" failonerror="false">
+                <arg value="-Dkotlin.colors.enbled=false"/>
                 <arg value="-cp"/>
                 <arg value="dependencies/bootstrap-compiler/Kotlin/kotlinc/lib/kotlin-compiler.jar"/>
                 <arg value="-script"/>

After finsiehd update_dependencies.xml, I executed ant -f build.xml and got following errors:

runner:
     [echo] Cleaning /home/kyungkoo/Downloads/kotlin-build-1.0.0-beta-5569/dist/classes/runner
    [mkdir] Created dir: /home/kyungkoo/Downloads/kotlin-build-1.0.0-beta-5569/dist/classes/runner
  [kotlinc] Compiling [/home/kyungkoo/Downloads/kotlin-build-1.0.0-beta-5569/compiler/cli/cli-runner/src] => [/home/kyungkoo/Downloads/kotlin-build-1.0.0-beta-5569/dist/classes/runner]

BUILD FAILED
/home/kyungkoo/Downloads/kotlin-build-1.0.0-beta-5569/build.xml:441: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.jetbrains.kotlin.ant.KotlinCompilerBaseTask.execute(KotlinCompilerBaseTask.kt:92)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:435)
    at org.apache.tools.ant.Target.performTasks(Target.java:456)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
    at org.apache.tools.ant.Main.runBuild(Main.java:853)
    at org.apache.tools.ant.Main.startAnt(Main.java:235)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Caused by: java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no jansi in java.library.path, /tmp/libjansi-32-7100610475620258495.so: /tmp/libjansi-32-7100610475620258495.so: cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)]
    at org.fusesource.hawtjni.runtime.Library.doLoad(Library.java:182)
    at org.fusesource.hawtjni.runtime.Library.load(Library.java:140)
    at org.fusesource.jansi.internal.CLibrary.<clinit>(CLibrary.java:37)
    at org.jetbrains.kotlin.cli.common.messages.PlainTextMessageRenderer.<clinit>(PlainTextMessageRenderer.java:35)
    at org.jetbrains.kotlin.cli.common.messages.MessageRenderer.<clinit>(MessageRenderer.java:29)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execFullPathsInMessages(CLICompiler.java:69)
    ... 22 more

Total time: 1 minute 3 seconds

I fixed build.xml like this:

diff --git a/build.xml b/build.xml
index 38f751c..7bcfeb1 100644
--- a/build.xml
+++ b/build.xml
@@ -299,6 +299,7 @@

             <java classname="org.jetbrains.kotlin.preloading.Preloader" failonerror="true" fork="true"
                   maxmemory="${max.heap.size.for.forked.jvm}">
+                <sysproperty key="kotlin.colors.enabled" value="true"/>
                 <classpath>
                     <pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
                 </classpath>
@@ -468,6 +469,7 @@
               failonerror="true"
               fork="true"
               maxmemory="${max.heap.size.for.forked.jvm}">
+            <sysproperty key="kotlin.colors.enabled" value="true"/>
             <assertions>
                 <enable/>
             </assertions>
@@ -732,6 +734,7 @@
             <pathconvert property="src.line" refid="src.dirset" pathsep=" "/>

             <java classname="org.jetbrains.kotlin.preloading.Preloader" failonerror="true" fork="true" maxmemory="${max.heap.size.for.forked.jvm}">
+                <sysproperty key="kotlin.colors.enabled" value="true"/>
                 <classpath>
                     <pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
                 </classpath>
@@ -771,6 +774,7 @@

         <sequential>
             <java classname="org.jetbrains.kotlin.preloading.Preloader" failonerror="true" fork="true" maxmemory="${max.heap.size.for.forked.jvm}">
+                <sysproperty key="kotlin.colors.enabled" value="true"/>
                 <classpath>
                     <pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
                 </classpath>

and then, I execute ant build. ant -f build.xml -Dkotlin.colors.enabled=false. I'm not good at ant. So, I can not sure that this is correct syntax. but build was started and I got same error.

BUILD FAILED
/home/kyungkoo/Downloads/kotlin-build-1.0.0-beta-5569/build.xml:442: java.lang.reflect.InvocationTargetException

...

Caused by: java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no jansi in java.library.path, /tmp/libjansi-32-7323034426853998701.so: /tmp/libjansi-32-7323034426853998701.so: cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)]
    at org.fusesource.hawtjni.runtime.Library.doLoad(Library.java:182)
    at org.fusesource.hawtjni.runtime.Library.load(Library.java:140)
    at org.fusesource.jansi.internal.CLibrary.<clinit>(CLibrary.java:37)
    at org.jetbrains.kotlin.cli.common.messages.PlainTextMessageRenderer.<clinit>(PlainTextMessageRenderer.java:35)
Kyungkoo
  • 11
  • 3
  • 1
    May be this is a reason: `Possible cause: can't load IA 32-bit .so on a ARM-bit platform`. You have installed Intel binaries only, but ARM is needed. – Eugene Krivenja Jan 08 '16 at 11:02
  • https://youtrack.jetbrains.com/issue/KT-10605 I submitted this bug to JetBrains. – Ruslan Jan 09 '16 at 12:39

3 Answers3

3

Looks like jansi native libraries are missing for Raspberry Pi. I'm not sure if they should be available, but you can safely disable them while building Kotlin because Kotlin compiler only uses jansi to output colored diagnostic messages to the terminal. To disable the use of colors (and hence jansi), try applying this patch in the root of the Kotlin project:

diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/PlainTextMessageRenderer.java b/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/PlainTextMessageRenderer.java
index e83309d..d4755e6 100644
--- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/PlainTextMessageRenderer.java
+++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/PlainTextMessageRenderer.java
@@ -32,9 +32,7 @@ import static org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
 public abstract class PlainTextMessageRenderer implements MessageRenderer {
     // AnsiConsole doesn't check isatty() for stderr (see https://github.com/fusesource/jansi/pull/35).
     // TODO: investigate why ANSI escape codes on Windows only work in REPL for some reason
-    private static final boolean COLOR_ENABLED =
-            !SystemInfo.isWindows &&
-            CLibrary.isatty(CLibrary.STDERR_FILENO) != 0;
+    private static final boolean COLOR_ENABLED = false;

     private static final String LINE_SEPARATOR = LineSeparator.getSystemLineSeparator().getSeparatorString();
Alexander Udalov
  • 31,429
  • 6
  • 80
  • 66
  • Thank you. but even though I changed like you, it doesn't work. :( I changed COLOR_ENABLED=false and rebuilded new source but crached. – Kyungkoo Jan 11 '16 at 02:46
  • Does it crash with the same error or another one? In any case, could you please edit your question to include the new stack trace? – Alexander Udalov Jan 11 '16 at 12:24
  • I got same error. It also crashed at `org.jetbrains.kotlin.cli.common.messages.PlainTextMessageRenderer.(PlainTextMessageRenderer.java:35)`. – Kyungkoo Jan 12 '16 at 00:55
  • I think when I changed `COLOR_ENABLED` value but when compiled it, `PlainTextMessageRenderer.java` is not compiled again. – Kyungkoo Jan 13 '16 at 04:40
  • I see now that the problem is in the bootstrap compiler, which is just an artifact downloaded in update_dependencies. So colors must be disabled in an already built compiler located in `dependencies/bootstrap-compiler/Kotlin/kotlinc/lib/kotlin-compiler.jar`. I'll commit a change allowing that soon. – Alexander Udalov Jan 13 '16 at 11:26
  • Thank you :D. Could I ask when is the next release? – Kyungkoo Jan 18 '16 at 00:58
  • I've committed the change: https://github.com/JetBrains/kotlin/commit/b0627b4. Please try adding `` to `` in target `override-version` in update_dependencies.xml – Alexander Udalov Jan 18 '16 at 14:31
  • Yeah, you have to basically pass this option to every instance of the compiler run in `build.xml`. First of all, ant should be run with it: `ant -Dkotlin.colors.enabled=false`. Second, everywhere where a Kotlin compiler is run in a new process (fork=true), pass a system property: ``. Let me know if you need further help – Alexander Udalov Jan 19 '16 at 15:01
  • I updated my question. And one more thing. Even though I fixed `PlainTextMessageRenderer.java` 35line, build.xml doesn't care about. I don't why. – Kyungkoo Jan 20 '16 at 09:59
  • Sorry, I made a typo, should be `... value="false"/>` of course :( – Alexander Udalov Jan 20 '16 at 11:06
  • I also tried but, it doesn't work. I got same error. I executed ant using this command `ant -f build.xml -Dkotlin.colors.enabled=false`. Is this correct? – Kyungkoo Jan 20 '16 at 11:19
  • Could you please try running `ANT_OPTS=-Dkotlin.colors.enabled=false ant`? – Alexander Udalov Jan 20 '16 at 11:46
  • I added `export ANT_OPTS="-Dkotlin.colors.enabled=false -Xmx1024m"`, and then, execute `ant -f build.xml`. It took 4hours and suddenly, process is killed. anyway, I executed 'dist/kotlinc/kotlinc-jvm' and got error `Exception in thread "main" java.lang.reflect.InvocationTargetException`. – Kyungkoo Jan 21 '16 at 11:27
2

I was just trying to get Kotlin to work on my Raspberry Pi as well. I followed the link above - https://youtrack.jetbrains.com/issue/KT-10605 - from IRus. From that I saw that it does check a property to disable color, fortunately.

So, at least for now until the change is propagated, you can do the following:

kotlinc -Dkotlin.colors.enabled=false

which will then skip the part that tries to load a non-ARM shared library. At least it works for me to get the REPL running.

Another way I found is to set the env variable JAVA_TOOL_OPTIONS like so:

export JAVA_TOOL_OPTIONS="-Dkotlin.colors.enabled=false"

this will be picked up by the java vm and then you do not need it on every command line (though it does spit out an annoying 'Picked up message' every time.

0

The command line Kotlin compiler developed by jetbrains can be installed as a snap package in all currently supported versions of Ubuntu. To install it, open the terminal and type:

sudo snap install kotlin --classic  

Available tools:

  • kotlinc
  • kotlinc-jvm
  • kotlinc-js
  • kotlin-dce-js
karel
  • 5,489
  • 46
  • 45
  • 50