renatoathaydes / osgi-run

Osgi-Run - A Gradle plugin to make the development of modular applications using OSGi completely painless
Apache License 2.0
54 stars 13 forks source link

Unable to create system terminal on runOsgi task. #71

Open Angular-Angel opened 2 years ago

Angular-Angel commented 2 years ago

When I use the 'runOsgi' task, it gives me:

Feb 14, 2022 12:13:34 PM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)

And then when I try the various commands in terminal, it doesn't seem to respond? But if I run 'stop 0' then a couple seconds later it will give some kind of error and shut down, so maybe it's getting the commands and responding to them, but just not giving me any output from them? :/

I found this other issue with the same error message, which was fixed by this commit, which updated the version of jline and added jansi, so maybe that's the issue? Though, I tried doing this on my end via adding those dependencies and it didn't change anything, even when I excluded any versions from osgi-run. :/

The text of that error I eventually get on telling it to 'exit' or 'stop 0':

Exception in thread "Thread-410" java.io.IOException: Stream closed
    at java.base/java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:168)
    at java.base/java.io.BufferedInputStream.read1(BufferedInputStream.java:289)
    at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:343)
    at java.base/java.io.FilterInputStream.read(FilterInputStream.java:106)
    at java_io_FilterInputStream$read.call(Unknown Source)
    at com.athaydes.gradle.osgi.RunOsgiTask$_consume_closure1.doCall(RunOsgiTask.groovy:90)
    at com.athaydes.gradle.osgi.RunOsgiTask$_consume_closure1.doCall(RunOsgiTask.groovy)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:274)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1035)
    at groovy.lang.Closure.call(Closure.java:412)
    at groovy.lang.Closure.call(Closure.java:406)
    at groovy.lang.Closure.run(Closure.java:493)
    at java.base/java.lang.Thread.run(Thread.java:833)

This problem occurs both when running via netbeans, and when running via xfce4-terminal. When I run the 'createOsgi' task and then manually run via terminal as below, however, it does not have any problem creating a system terminal and I can use full functionality.

./gradlew createOsgi

chmod +x build/osgi/run.sh
build/osgi/run.sh
renatoathaydes commented 2 years ago

@Angular-Angel I've had a look, the runOsgi task is not working anymore since the Gradle upgrade even on MacOS (where I develop). I tried for several hours to make it work again but Gradle seems to be doing something that makes it impossible to run any interactive command at all.

I am open to suggestions, as everything I tried failed.

My attempts:

renatoathaydes commented 2 years ago

I think the reason for this is that Gradle starts a daemon to run the build, and it's impossible to inherit IO from a daemon as the daemon is not a child process, it's a remote process. I tried to get rid of the daemon with --no-daemon, but Gradle insists in forking a JVM to run the build anyway, which causes the same problem as the forked JVM is not inheriting IO either, as it seems.

See this discussion on the ineffectiveness of --no-daemon.

I think I will remove this task from the plugin, unfortunately. It seems to me that having Gradle allow this is a losing battle. Using the launcher script that createOsgi creates is about as easy anyway... do you have a strong reason to prefer runOsgi?

Angular-Angel commented 2 years ago

It's a lot easier in my IDE, just double-clicking a thing, vs opening a terminal and running two commands. I'd say leave it in, unless that requires a lot more work or something.

renatoathaydes commented 2 years ago

See if you can completely eliminate the Gradle daemon or even forking a new JVM, and I bet it will work again.

Angular-Angel commented 2 years ago

I don't even begin to know how to do that. :/

Angular-Angel commented 2 years ago

Actually, maybe what you want is some kind of fancy 'Connect Terminals' Command? That seems like it should be possible, but I have no idea how. :/