Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create system terminal on runOsgi task. #71

Open
Angular-Angel opened this issue Feb 16, 2022 · 6 comments
Open

Unable to create system terminal on runOsgi task. #71

Angular-Angel opened this issue Feb 16, 2022 · 6 comments

Comments

@Angular-Angel
Copy link

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
Copy link
Owner

@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:

  • current solution - start Threads to consume the child process' stdin, stdout, stderr (used to work).
  • try new ProcessBuilder().inheritIO()... (doesn't actually inherit either stdin or stdout)
  • use JavaExec setting standardInput to System.in - I couldn't figure out why the process errors no matter what I tried as it doesn't show the reason why it errors.

@renatoathaydes
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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

@Angular-Angel
Copy link
Author

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

@Angular-Angel
Copy link
Author

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. :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants