rubyinstaller2 icon indicating copy to clipboard operation
rubyinstaller2 copied to clipboard

Windows Ruby 3.1 - Open3 #capture2 causes IRB console to become unresponsive

Open johnnyshields opened this issue 2 years ago • 20 comments

I have also filed a ticket with ruby/open3 repo here: https://github.com/ruby/open3/issues/9, but this seems more like a Windows-specific issue as it works on Linux/Mac.

The following script will cause IRB console to become unresponsive on Ruby 3.1 on Windows installed by the Windows Ruby Installer x64-mingw-ucrt. This is using the version of Open3 packaged with Ruby (0.1.1)

$> irb

require 'open3'
Open3.capture2('ver')

# after this, the IRB console becomes unresponsive

johnnyshields avatar Jun 26 '22 06:06 johnnyshields

Hi @johnnyshields - I did a quick check with your sample on my side, and it seems to work as expected. This is in the Windows console (cmd).

$ ruby -v
ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x64-mingw-ucrt]

$ irb
irb(main):001:0> require 'open3'
=> true
irb(main):002:0> Open3.capture2('ver')
=> ["\nMicrosoft Windows [Version 10.0.19044.1766]\n", #<Process::Status: pid 13272 exit 0>]
irb(main):003:0> (0..2).each {|x| puts "Hello #{x}"}
Hello 0
Hello 1
Hello 2
=> 0..2
irb(main):004:0> exit

Just adding this here in case it helps to debug what the difference might be.

mohits avatar Jun 26 '22 13:06 mohits

@mohits thanks for checking this, this is very useful. Hmmm very strange. Possibly something specific to my system.

Quite bizarre tho as Ruby 3.0 and earlier don't have the same issue.

johnnyshields avatar Jun 26 '22 13:06 johnnyshields

@johnnyshields - I checked both Ruby 3.0 and Ruby 3.1 on my system (though I only posted the result from 3.1) and both worked fine. The installation is also bog-standard - https://notepad.onghu.com/2022/ruby3.1-windows-day0-install-hello_world/ - nothing special in it.

mohits avatar Jun 26 '22 14:06 mohits

@mohits I appreciate it.

johnnyshields avatar Jun 26 '22 14:06 johnnyshields

The following script will cause IRB console to become unresponsive on Ruby 3.1

Testing with Ruby 3.1.2 and Ruby master (ruby 3.2.0dev (2022-06-26T02:16:11Z master a782d76fbe) [x64-mingw-ucrt]), I have the same result.

MSP-Greg avatar Jun 26 '22 14:06 MSP-Greg

Any further thoughts on this issue?

johnnyshields avatar Oct 17 '22 11:10 johnnyshields

same is happening to me and it is making nokigiri installation fail

> gem install nokogiri
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
#<Thread:0x0000013ef5ede448 C:/Programming/Ruby/rubyinstaller-3.2.0-1-x64/lib/ruby/3.2.0/open3.rb:404 run> terminated with exception (report_on_exception is true):
C:/Programming/Ruby/rubyinstaller-3.2.0-1-x64/lib/ruby/3.2.0/open3.rb:404:in `read': stream closed in another thread (IOError)
        from C:/Programming/Ruby/rubyinstaller-3.2.0-1-x64/lib/ruby/3.2.0/open3.rb:404:in `block (2 levels) in capture2e'
ERROR:  Interrupted

P3t3rU5 avatar Jan 01 '23 20:01 P3t3rU5

Test report: gem install nokogiri on Windows 11 (10.0.22621.1105) with Ruby 3.2.0-1 works fine.

I think this may relate to some specific Windows versions.

ccmywish avatar Jan 11 '23 07:01 ccmywish

Seems like MSYS was the issue here - installed on top of my previous installation and it started working

P3t3rU5 avatar Jan 19 '23 23:01 P3t3rU5

nevermind... seemed to work but when doing bundler update it gets stuck trying to install nokogiri

P3t3rU5 avatar Jan 20 '23 03:01 P3t3rU5

This issue is still persisting with the officially released Windows RubyInstaller for Ruby 3.2.0

johnnyshields avatar Jan 23 '23 09:01 johnnyshields

Hey, I can confirm I have the issue as well here - Windows 11 [Version 10.0.22621.1702] and ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x64-mingw-ucrt] .

OursCodeur avatar May 15 '23 22:05 OursCodeur

Not sure if this is an Open3 issue, as the following work. Might be an irb issue?

ruby -e "require 'open3'; puts Open3.capture2('ver')"
ruby -e "require 'open3'; Thread.new { puts Open3.capture2('ver') }.join"

MSP-Greg avatar May 15 '23 22:05 MSP-Greg

What started the investigation on my side was using mjml-rails in a regular project on Windows - which relies on Open3 to run MJML itself (here). Capture3 causes ruby to hang up indefinitely, which I can reproduce in irb.

I can also confirm @MSP-Greg 's commands do not cause the issue.

Hope the additional context helps somehow.

OursCodeur avatar May 15 '23 22:05 OursCodeur

Technically speaking IRB does not “crash” either, but its state is altered so that it no longer accepts inputs.

So the fact that the ruby -e commands don’t crash maybe doesn’t tell us a whole lot.

On Mon, May 15, 2023 at 18:32 Thomas Portal @.***> wrote:

What started the investigation on my side was using rails-mjml in a regular project on Windows - which relies on Open3 to run MJML itself ( here https://github.com/sighmon/mjml-rails/blob/a1b90616b9e9aff594c43e40f536d4e80a349612/lib/mjml.rb#L41). Capture3 causes ruby to hang up indefinitely, which I can reproduce in irb.

I can also confirm @MSP-Greg https://github.com/MSP-Greg 's commands do not cause the issue.

Hope the additional context helps somehow.

— Reply to this email directly, view it on GitHub https://github.com/oneclick/rubyinstaller2/issues/288#issuecomment-1548702814, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAGYB43YEOIPKR2DC7LQZLXGKVH7ANCNFSM5Z3NA52A . You are receiving this because you were mentioned.Message ID: @.***>

--

Johnny Shields

Founder & CTO

[image: TableCheck] https://www.tablecheck.com/en/company/ [image: Address] Dai 27 Chuo Bldg 4F, 2-14-5 Ginza, Chuo-ku, Tokyo, Japan 104-0061 https://goo.gl/maps/G4PyDSZE8s32 [image: Phone] +81 (0)80-3519-5647 [image: Web] @.*** https://www.tablecheck.com/en/company/

johnnyshields avatar May 15 '23 23:05 johnnyshields

Trying to work my way around Open3, I've also been able to reproduce the IRB hang with systemu('env') .

OursCodeur avatar May 16 '23 15:05 OursCodeur