rcaller
rcaller copied to clipboard
auto-detection of rscript/r should not override user settings
This code looks valid to me but fails to run
Globals.R_current = "/usr/local/bin/R"
Globals.Rscript_current= "/usr/local/bin/RScript"
val code = RCode.create()
val rCaller = RCaller.create(code, RCallerOptions.create())
code.addRCode("1+1")
rCaller.runOnly()
The error is
Exception in thread "main" com.github.rcaller.exception.ExecutionException: Can not run /usr/bin/Rscript. Reason: java.io.IOException: Cannot run program "/usr/bin/Rscript": error=2, No such file or directory
at com.github.rcaller.rstuff.RCaller.runRCode(RCaller.java:212)
at com.github.rcaller.rstuff.RCaller.runOnly(RCaller.java:190)
at com.r4intellij.RCallerDemoKt.main(RCallerDemo.kt:34)
The reasons seems that com.github.rcaller.rstuff.RCallerOptions#create() is overriding my custom settings by calling Globals.detect_current_rscript(); internally. The latter should check if the user has set own defaults before detecting R (which also lacks support for macos)
The only possible workaround seems to call the full signature factory method manually (which seems tedious to me):
val rCaller = RCaller.create(code, RCallerOptions.create(Globals.Rscript_current, Globals.R_current, FailurePolicy.RETRY_5, 9223372036854775807L, 100L, RProcessStartUpOptions.create()))
@holgerbrandl have you any solutions or pull requests for this?
Not really. It's been quite a while since I was looking into the problem.
it worked for me with this (under linux) :
RCode rcode = RCode.create();
rcode.addRCode("code....");
RCallerOptions options = RCallerOptions.create(Globals.RScript_Linux, Globals.R_Linux, FailurePolicy.RETRY_1, 3000l, 100l, RProcessStartUpOptions.create());
RCaller rcaller = RCaller.create(rcode, options);
rcaller.runAndReturnResult("result");
but under windows, it seems that my probleme come from the fact that i don't have an admin account in my work computer, so in options, i give the path "C:\Users\.....\R\R-4.0.3\bin\Rscript.exe"