callr icon indicating copy to clipboard operation
callr copied to clipboard

Customize R binary

Open rickhelmus opened this issue 5 years ago • 5 comments

Hello,

At the moment it doesn't seem to be possible to run a different installed R version (i.e. override the binary path). This might come in handy for a package I'm using which doesn't work with the latest R (yet).

Thanks, Rick

rickhelmus avatar Nov 25 '18 18:11 rickhelmus

Can you always pass RData files between different R versions?

Anyway, if you want to run another R version, you can always use processx::run() or processx::process directly.

gaborcsardi avatar Mar 11 '19 11:03 gaborcsardi

Can you always pass RData files between different R versions?

Anyway, if you want to run another R version, you can always use processx::run() or processx::process directly.

Perhaps, but I like the 'callr' interface and there is no documentation on how to use it with a processx object.

Could we not simply add bin= to the r_process_options() and prefer this value to R.home("bin")? (Will probably need to seyt .libPaths too...)

cybaea avatar Jan 22 '21 14:01 cybaea

I think it might be better to have a new r_version() function, which runs the selected version.

gaborcsardi avatar Jan 24 '21 10:01 gaborcsardi

With the fix of #95, much of this already works. However the library path setup still needs work, we probably need to unset some env vars like R_HOME, and determine the version of RDS we can use. Plus we would need a proper API for it, instead of specifying the executable directly.

❯ r(function() getRversion(), arch = "/Library/Frameworks/R.framework/Versions/3.5/Resources/bin/R")
[1] ‘3.5.3’

❯ r(function() getRversion(), arch = "/Library/Frameworks/R.framework/Versions/3.4/Resources/bin/R")
Error: callr subprocess failed: cannot read workspace version 3 written by R 4.0.4; need R 3.5.0 or newer
Type .Last.error.trace to see where the error occured

❯ r(function() getRversion(), arch = "/Library/Frameworks/R.framework/Versions/3.6/Resources/bin/R")
Error in get_result(output = out, options) :
  callr subprocess failed: could not start R, exited with non-zero status, has crashed or was killed
Type .Last.error.trace to see where the error occured

❯ .Last.error$stdout
[1] "WARNING: ignoring environment value of R_HOME\n"

gaborcsardi avatar Mar 23 '21 10:03 gaborcsardi

Personally I think version=2 in all saveRDS calls is definitely good enough. It supports all R versions >=1.4, AFAIK without any loss of functionality. Regarding API: specifying executable+libpath directly seems unavoidable, but probably better to set defaults in some setup call and not in every r call.

OfekShilon avatar Jul 11 '21 08:07 OfekShilon