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

highline 1.6.9 hangs indefinitely with JRuby #31

Closed
graaff opened this issue Jan 16, 2012 · 18 comments
Closed

highline 1.6.9 hangs indefinitely with JRuby #31

graaff opened this issue Jan 16, 2012 · 18 comments

Comments

@graaff
Copy link

graaff commented Jan 16, 2012

With jruby 1.5.6 (ruby 1.8.7 patchlevel 249) (2012-01-08 6586) (OpenJDK 64-Bit Server VM 1.6.0_22) [amd64-java] tests hang indefinitely. I've tested both with and without your patch for my ruby 1.8 bug. It shows two dots when running its tests and then hangs. I realize that our jruby is old but we can't currently upgrade since 1.6 versions don't run properly on our system.

@JEG2
Copy link
Owner

JEG2 commented Jan 16, 2012

In understand. However, this is an old JRuby and we're just talking about the tests, right?

Does the library still work or is it also broken?

@graaff
Copy link
Author

graaff commented Jan 16, 2012

Not sure since I only tried the tests, and I don't have a clear test case for the code. I'm doing this testing so that I can add the new version to Gentoo Linux. I can understand if you want to put this on hold until we upgrade to a new jruby version.

@JEG2
Copy link
Owner

JEG2 commented Jan 18, 2012

Yeah, I actually think that may be older than what we now support. We use JLine under the hood and I can't seem to find when that was added to JRuby, but I believe it's recent-ish.

We couldn't really find another working option for JRuby support, so I think we need it unless someone offers up another solution.

@tomdz
Copy link

tomdz commented Jan 18, 2012

jline seems to have been in JRuby since about 1.6.0 or 1.6.1 (april 2011). Would it be more better if highline has its own jline bundled ? I.e. a highline-java version that includes jline (similar to jruby) ?

@JEG2
Copy link
Owner

JEG2 commented Jan 19, 2012

That might be an option. Would JLine run on the older JRuby versions?

@tomdz
Copy link

tomdz commented Jan 19, 2012

I don't think jline integration needs a lot of jruby features, so it should work with, say, 1.5.6. Bigger problem is the bundling - the jline jar itself is somewhat big, so a highline-java or even highline-jruby-old variant (since with 1.6.x the separate jar is not needed anymore) might be a good idea ?

@JEG2
Copy link
Owner

JEG2 commented Jan 19, 2012

Yeah, this is sounding like some hassle to support some pretty old stuff. I'm feeling like it's not worth the bother. Do you guys disagree?

@graaff
Copy link
Author

graaff commented Jan 22, 2012

It looks like our jruby 1.5.6 already has jline support. Also, with that version all tests pass for highline 1.6.8 pass. So unless something changed accordingly in highline 1.6.9 it may still be another problem. In any case I'm fine with postponing this until we can test with jruby 1.6.

@JEG2
Copy link
Owner

JEG2 commented Jan 23, 2012

OK, closing this for now.

@JEG2 JEG2 closed this as completed Jan 23, 2012
@Flameeyes
Copy link
Contributor

Okay I think I found the problem. The test contains:

@input    = StringIO.new
@output   = StringIO.new
@terminal = HighLine.new(@input, @output)  

Unfortunately, in the case of JRUBY, the two parameters are ignored:

  @java_input = Channels.newInputStream($stdin.to_channel)
  @java_output = OutputStreamWriter.new(Channels.newOutputStream($stdout.to_channel))
  @java_terminal = Terminal.getTerminal
  @java_console = ConsoleReader.new(@java_input, @java_output)
  @java_console.setUseHistory(false)
  @java_console.setBellEnabled(true)

simply using @input.to_channel and @output.to_channel don't seem to work though.

@graaff
Copy link
Author

graaff commented Aug 14, 2012

This issue should probably be re-opened because this hang still happens with jruby 1.6.7.2 (ruby-1.8.7-p357) (2012-05-17 fffffff) (OpenJDK 64-Bit Server VM 1.6.0_24) [linux-amd64-java]

@graaff
Copy link
Author

graaff commented Aug 14, 2012

Forgot to add that this still happens with highline 1.6.13.

@JEG2 JEG2 reopened this Aug 14, 2012
@JEG2
Copy link
Owner

JEG2 commented Aug 14, 2012

I'll try to look into this when I have some time.

@mnzaki
Copy link
Contributor

mnzaki commented Aug 22, 2012

I have faced this problem while working on the jruby 1.7 support. I have made some preliminary changes that will alleviate the hang, but 18 tests fail.
The problem as of now (mnzaki/highline@2daa26e) is that the output contains the input that was passed as well, so the asserts fail. I think this happens because when using jline the ConsoleReader echos the input (unless you explicitly turn it off) while other methods depend on the underlying system to echo characters. One solution I see is to not even create a ConsoleReader when @input.tty? is false

@JEG2
Copy link
Owner

JEG2 commented Aug 22, 2012

Yeah, that sounds reasonable. I would welcome such a fix.

rsutphin added a commit to rsutphin/highline that referenced this issue Feb 23, 2013
Before this commit, the input and output parameters to HighLine.new
were ignored for #ask (both for specifying the input stream and for
displaying the prompt).

This commit fixes issue JEG2#31, which was introduced by PR JEG2#27. Since
then, the HighLine tests have been unable to run on JRuby. With this
change, the tests run on JRuby 1.7.3 but many of them fail. No tests
fail on JRuby 1.7.3 using the version of HighLine from immediately
before JEG2#27 was merged, so it seems likely the failures were caused
by JEG2#27 also.

This commit stops using `SystemExtensions#initialize` to set up JLine.
It would have been possible to pass the input and output parameters to
the `super` call, but that seemed to me like an abuse of inheritance.
Instead, following the pattern of the rest of SystemExtensions, I
added a method called `initialize_system_extensions` which is defined
on a per-platform basis (currently for JRuby only) and invoked by
`HighLine#initialize` when present.
@abinoam
Copy link
Collaborator

abinoam commented Jul 20, 2015

It seems io/console is available on recent vesions of JRuby and it works pretty similar to how it works on MRI.
So I'm trying to unify the approaches for MRI and JRuby on this PR #149

The test suit just 'skips' the readline cases when at jruby. Because I couldn't figured out a way to test them. (If you know how to do it, please tell me so).
So the tests will not hang indefinitely (waiting for console user input).

But you can be sure that it is working fine by using rake acceptance
This rake task will show you some use cases of HighLine and ask you if it's working or not.

By skipping this particular readline case on test suit we have all tests passing in travis https://travis-ci.org/abinoam/highline (jruby-19mode)

Could you people interested in (and familiar to) JRuby support give some feedback about the PR #149 ?

Hooking anyone that has commented in any HighLine JRuby issue: @rsutphin @mnzaki @graaff @Flameeyes @tomdz @andlaz @jeremyd @rsutphin @kgx @thinkgareth @presidentbeef @JEG2 @alexch @stomar @BanzaiMan @ai @celeduc @oreoshake @antond @jcoyne @keshavkuruva @cfbrobak @astounding

@abinoam
Copy link
Collaborator

abinoam commented Jul 20, 2015

... and I think PR #149 also closes issue #51

@abinoam
Copy link
Collaborator

abinoam commented Sep 18, 2015

After PR #149 I think most of JRuby problems are gone. Closing.

@abinoam abinoam closed this as completed Sep 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants