r-lib / rig

The R Installation Manager
MIT License
625 stars 21 forks source link

Run subprocess with a different R version #29

Open krlmlr opened 2 years ago

krlmlr commented 2 years ago

via new rim run command?

$ R --version
R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.

$ rim run 3.5 R --version
R version 3.5.3 (2019-03-11) -- "Great Truth"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
http://www.gnu.org/licenses/.
gaborcsardi commented 2 years ago

rim creates links for all R versions via rim system make-links, which is called automatically if you install with rim. So this is just

❯ R-3.6 --version
R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.
gaborcsardi commented 2 years ago

@krlmlr Is this ^^ good? Does rim run have any advantage?

krlmlr commented 2 years ago

I'm aware of the version-specific executables. I'd expect rim run to define $PATH in a way that ensures that R and perhaps other important executables point to the selected versions. This helps with subprocesses that are just calling R .

gaborcsardi commented 2 years ago

True. That does seem useful.

gaborcsardi commented 2 years ago

Maybe we could also use this to run a different versions of R in the RStudio terminal, which is not great currently because of the many R_* env vars that are set there. E.g. R_LIBS_USER messes up the library path, etc.