I'm trying to make an .exe from a simple perl script that uses the Statistics::R package.
use Statistics::R;
use strict;
my $R = Statistics::R->new();
$R->startR;
$R->send('x=10');
$R->send('x');
my $ret = $R->read;
print $ret;
$R->stopR();
Everything works fine until I create the perlapp .exe file. When I test this, I get the following errors:
Inappropriate I/O control operation: Win32::Process::Create() at /<C:\@programming\r\trying_r_bridge.exe>IPC/Run.pm line 2105
Inappropriate I/O control operation: Win32::Process::Create() at /<C:\@programming\r\trying_r_bridge.exe>IPC/Run.pm line 2224
Inappropriate I/O control operation: Win32::Process::Create() at /<C:\@programming\r\trying_r_bridge.exe>IPC/Run.pm line 2224
I looked online and found this thread about the problem: http://www.nntp.perl.org/group/perl.par/2011/05/msg5022.html
This is what they say:
this happens because the IPC::Run module on Win32 (only) tries to run subprocesses using $^X, which normally contains the path to perl.exe. However, when PAR packs an executable, $^X doesn't happen to point to perl.exe, and so IPC::Run fails at that point. Implementing IPC::Run on Windows without using subprocesses is an unsolved problem.
In the end, the thread solution is to use IPC::Run3, which is not an option here.
Any suggestions for how to overcome this problem?
I have rewritten almost entirely Statistics::R in the last year to make it faster, platform-independent and robust. I chose to perform the calls to R and various IOs through IPC::Run.
Apparently, the issue seems you describe is specific to IPC::Run. So, you should first file a ticket on the IPC::Run tracker. I do not know how feasible for the authors of IPC::Run to implement a fix, but the least they can do is have a caveat section that describes the incompatibility.
Using IPC::Run3 instead of IPC::Run in Statistics::R may be an option if it satisfies the requirements of Statistics::R (mainly communicate with R using stdin, stdout and stderr). It would not a drop-in replacement, so, not a trivial change.