Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto-detection of rscript/r should not override user settings #28

Open
holgerbrandl opened this issue Apr 27, 2017 · 4 comments
Open

auto-detection of rscript/r should not override user settings #28

holgerbrandl opened this issue Apr 27, 2017 · 4 comments

Comments

@holgerbrandl
Copy link

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)

@holgerbrandl
Copy link
Author

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()))

@jbytecode
Copy link
Owner

@holgerbrandl have you any solutions or pull requests for this?

@holgerbrandl
Copy link
Author

Not really. It's been quite a while since I was looking into the problem.

@yassineaminTalan
Copy link

yassineaminTalan commented Nov 10, 2020

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants