Using Ruby's popen3 or equivalent on Windows

1.1k Views Asked by At

I'm making a Vim plugin that uses Open3.popen3 to run a shell command, and I need the result and exit code. It works fine on Linux, but freezes on Windows. I've checked on pry under Windows and whenever I run Open3.popen3 or Process.spawn the shell just freezes. I've tried to install the win32-open3-19 gem(and load it with require 'win32/open3) - but it still freezes.

Is there any other method or gem I can use? I prefer something as close as possible to Open3(so my Linux and Windows versions can share as much code as possible).

I'm running Ruby 1.9.3 installed via RubyInstaller on Windows 7 64bit.

MORE DETAILS:

This is the exact code I want to run: https://github.com/someboddy/vim-erroneous/blob/master/autoload/erroneous.rb#L43

It works on Linux but freezes on Windows.

On my Windows, I open pry and then write:

require 'win32/open3'
inp,out,err,wait_thr=Open3.popen3('cmd')

And my shell freezes. When I try it on Linux(using 'bash' instead of 'cmd') it works just fine. I've also tried 'dir'(which shouldn't wait for user input) and it also froze.

0

There are 0 best solutions below