This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 148472 - IO.popen block hangs NetBeans script execution when using JRuby
Summary: IO.popen block hangs NetBeans script execution when using JRuby
Status: NEW
Alias: None
Product: ruby
Classification: Unclassified
Component: Platform (show other bugs)
Version: 6.x
Hardware: Macintosh Mac OS X
: P3 blocker (vote)
Assignee: issues@ruby
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-26 12:14 UTC by jskovzoftcorpdk
Modified: 2011-01-28 20:12 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jskovzoftcorpdk 2008-09-26 12:16:02 UTC
I have created a ruby project in NetBeans 6.5Beta. I am using JRuby 1.1.4.
I am trying to execute some external commands, from a Ruby script in the project.
I am using the following construct:

-----
IO.popen("/bin/echo HELLO") { | f |
  while (l = f.gets())
    puts l
  end
}
puts "If only this would execute..."
-----

When I run the code with shift-F6, it prints out "HELLO", but then appears to hang.

If I change the project to use the JRuby 1.1.3 that came with NetBeans, the same thing happens.

If I use the native ruby 1.8.6, it works fine.


If I run the script directly from native ruby or either JRuby versions, it works fine (i.e. terminates after printing
both strings).


I guess I will try to use the Kernel.system() command as a workaround, as it appears to work. Obviously, I would like to
be able to use IO.popen() in my scripts from within NetBeans.
Comment 1 Martin Krauskopf 2008-09-26 12:25:10 UTC
Hi. I've just tried this with latest build (could you try it instead of 6.5 beta, which is little obsolete):

  http://wiki.netbeans.org/RubyInstallation#section-RubyInstallation-HowDoIGetTheContinuousBuilds

with:

- Bundle-in JRuby 1.1.4
- JRuby trunk
- MRI

from NetBeans and from CLI and it works for me in all cases (Linux, but should not matter here, I guess).

Is not the case that the line:

  puts "If only this would execute..."

is not just printed - this is known issue, see issue 114476.

Might be confirmed by looking at the state of ReRun and Stop button in the Output Window. What is their state after the
program 'finish'. Is the Stop or ReRun button disabled?
Comment 2 jskovzoftcorpdk 2008-09-26 12:40:12 UTC
I tried with
http://deadlock.netbeans.org/hudson/job/trunk/lastStableBuild/artifact/nbbuild/dist/zip/netbeans-hudson-trunk-3870-ruby.zip

It had the same behavior - hangs with the inbuilt JRuby 1.1.4, runs to completion with native 1.8.6.

The script hangs - the Stop button is enabled.
Comment 3 Martin Krauskopf 2008-09-26 13:08:21 UTC
Hmmm, strange. The difference is that we run JRuby through 'java'. If you turned on logging as described here:

  http://wiki.netbeans.org/FaqRubyNBLogging

and run NetBeans you will see in the log line like:

  FINE [org.netbeans.modules.ruby.platform.execution.ExecutionService]: Running: (basedir: /home/emdot/ruby/tester/lib)
"/space/java/jdk1.5.0_15/jre/bin/java -Xverify:none ...

Could you run that line from command line? Does it work for you? Thanks.
Comment 4 jskovzoftcorpdk 2008-09-26 14:38:08 UTC
The full output related to the execution was:

FINE [org.netbeans.modules.ruby.platform.execution.ExecutionService]: Running: (basedir: /opt/rb)
"/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java -Xverify:none -da -Xmx512m -Xss1024k
-classpath
/opt/x/netbeans/ruby2/jruby-1.1.4/lib/bsf.jar:/opt/x/netbeans/ruby2/jruby-1.1.4/lib/jruby.jar:/opt/x/netbeans/ruby2/jruby-1.1.4/lib/profile.jar:
-Djruby.base=/opt/x/netbeans/ruby2/jruby-1.1.4 -Djruby.home=/opt/x/netbeans/ruby2/jruby-1.1.4
-Djruby.lib=/opt/x/netbeans/ruby2/jruby-1.1.4/lib -Djruby.shell=/bin/sh -Djruby.script=jruby org.jruby.Main -I/opt/rb
-I/opt/rb/view -I/opt/rb/core /opt/rb/utils/utils.rb"
FINE [org.netbeans.modules.ruby.platform.execution.ExecutionService]: Environment: {LANG=da_DK.UTF-8,
DISPLAY=/tmp/launch-AUEh4A/:0, TERM_PROGRAM_VERSION=240, PWD=/Users/jskov/.netbeans/dev/var/log,
_=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/bin/java,
GEM_HOME=/opt/x/netbeans/ruby2/jruby-1.1.4/lib/ruby/gems/1.8, JRUBY_BASE=/opt/x/netbeans/ruby2/jruby-1.1.4,
JRUBY_HOME=/opt/x/netbeans/ruby2/jruby-1.1.4, USER=jskov, SECURITYSESSIONID=80ebc0,
Apple_PubSub_Socket_Render=/tmp/launch-nf9rwG/Render, GEM_PATH=/opt/x/netbeans/ruby2/jruby-1.1.4/lib/ruby/gems/1.8,
HOME=/Users/jskov, TERM_PROGRAM=Apple_Terminal, JAVA_MAIN_CLASS_423=org.netbeans.Main, SHELL=/bin/bash, LOGNAME=jskov,
SSH_AUTH_SOCK=/tmp/launch-GifFl9/Listeners, SHLVL=2, J2D_PIXMAPS=shared,
TMPDIR=/var/folders/v+/v+KWw8tFFmKoMkckQfUcJU+++TI/-Tmp-/, __CF_USER_TEXT_ENCODING=0x1F5:0:0,
APP_ICON_423=/opt/x/netbeans/bin/../nb6.5/netbeans.icns, MANPATH=/usr/share/man:/usr/local/share/man:/usr/X11/man,
APP_NAME_423=NetBeans, COMMAND_MODE=unix2003, JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home,
TERM=xterm-color,
PATH=/opt/x/netbeans/ruby2/jruby-1.1.4/bin:/opt/pvr/jruby/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/opt/pvr/bin:/usr/local/mysql/bin}

When I execute the line directly, the script runs as expected - and returns.


I just noticed something weird. If I select the console window and press return, the second line is printed, and the
script returns (and the Rerun icon activates).



Comment 5 Martin Krauskopf 2008-09-26 14:49:01 UTC
Thanks for investigation. I guess I'll have to try it on Mac somewhere in the office, might be related to Mac JDK.

> If I select the console window and press return, the second line is printed

Seems like $stdin gets it into the game.

I'm leaving to vacation so I'll take a look at it when I get back.
Comment 6 jskovzoftcorpdk 2008-09-26 14:54:56 UTC
FWIW I also tried using the new JDK6 with the same result.
Comment 7 Martin Krauskopf 2008-10-13 15:57:02 UTC
Easily reproducible on Mac. Note that the script is not hung, it waits for <Enter>. When you activate the "hung" output
window and press enter, the script continues. Will have to evaluate the reason.