2

Do you know how to specify R binary which will be launched by Rscript?

It points to /usr/lib/R/bin/R by default.

$ Rscript --verbose -e 'Sys.getenv("R_HOME")'

running
  '/usr/lib/R/bin/R --slave --no-restore -e Sys.getenv("R_HOME")'

[1] "/usr/lib/R"

I have configured alternatives for /usr/bin/R, and can switch between R.

For R:

$ update-alternatives --display R
R - auto mode
  link currently points to /opt/R/3.2.3/usr/lib/R/bin/R
/opt/R/3.2.3/usr/lib/R/bin/R - priority 200
/usr/lib/R/bin/R - priority 100
Current 'best' version is '/opt/R/3.2.3/usr/lib/R/bin/R'.

For Rscript:

$ update-alternatives --display Rscript
Rscript - auto mode
  link currently points to /opt/R/3.2.3/usr/lib/R/bin/Rscript
/opt/R/3.2.3/usr/lib/R/bin/Rscript - priority 200
/usr/lib/R/bin/Rscript - priority 100
Current 'best' version is '/opt/R/3.2.3/usr/lib/R/bin/Rscript'.

I cannot find the way, how to force Rscript launch /usr/bin/R instead of /usr/lib/R/bin/R.


Update

@dirk-eddelbuettel has suggested to use environment PATH. Despite the set of PATH, Rscript still uses /usr/lib/R/bin/R

$ env | grep PATH
PATH=/opt/R/3.2.3/usr/lib/R/bin:/opt/python/conda/bin::/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

Launching Rscript

$ Rscript --version && Rscript --verbose -e 'print("Hello")'
    R scripting front-end version 3.2.3 (2015-12-10)
    running
      '/usr/lib/R/bin/R --slave --no-restore -e print("Hello")'

    [1] "Hello"
Cron Merdek
  • 1,084
  • 1
  • 14
  • 25

1 Answers1

0

You need different Rscript variants from two builds. I just do it via $PATH:

edd@max:~$ Rscript --version
R scripting front-end version 3.2.3 (2015-12-10)
edd@max:~$ Rscript-devel.sh --version
R scripting front-end version 3.3.0 Under development (unstable) (2016-02-07 r70118)
edd@max:~$ 

I could have called this anything. I chose to end it in .sh as it is a shell wrapper:

edd@max:~$ cat ~/bin/Rscript-devel.sh 
#!/bin/bash

export R_LIBS_SITE=${R_LIBS_SITE-'/usr/lib/R-devel/lib/R/library:/usr/local/lib/R/site-library:/usr/lib/R/site-library::/usr/lib/R/library'}
export PATH="/usr/local/lib/R-devel/bin:$PATH"
Rscript "$@"
edd@max:~$ 

Edit: As requested though I fail to understand why you cannot do that yourself:

edd@max:~$ Rscript --verbose -e '2+2'
running
  '/usr/lib/R/bin/R --slave --no-restore -e 2+2'

[1] 4
edd@max:~$ Rscript-devel.sh --verbose -e '2+2'
running
  '/usr/local/lib/R-devel/lib/R/bin/R --slave --no-restore -e 2+2'

[1] 4
edd@max:~$ 
Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • Can you please show output of `$ Rscript-devel.sh --version --verbose -e 'print("Dirk is awesome!")'`? – Cron Merdek Feb 10 '16 at 11:43
  • Would you mind please to show output of the `--verbose` for `Rscript-devel.sh`? – Cron Merdek Feb 10 '16 at 12:47
  • What you showed first behaves the same way as `Rscript --verbose` does. Both fail. It's built-in. Normal behaviour works. You try this yourself _which is why I showed you the whole script_. – Dirk Eddelbuettel Feb 10 '16 at 12:59
  • Hmm...I had done what you have suggested from the beggining, but in my case, despite set of `PATH` `Rscript-devel.sh` still calls `/usr/lib/R/bin/R` :( I will keep digging. – Cron Merdek Feb 10 '16 at 13:15
  • The PATH setting needs to correspond to where YOUR version of R-devel is installed. – Dirk Eddelbuettel Feb 10 '16 at 13:16
  • sure :) i am not simply copying your script, i have adjusted the location. In my case it is in `/opt/R/3.2.3/usr/lib/R/bin` and `/opt/R/3.2.3/usr/lib/R/library` – Cron Merdek Feb 10 '16 at 13:20
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/103104/discussion-between-cronacronis-and-dirk-eddelbuettel). – Cron Merdek Feb 10 '16 at 13:27
  • 3
    No, I don't have time for one on one tutoring. Feel free to post on the r-sig-debian list (or even on r-help). You have a simple deployment problem of your R-devel build. – Dirk Eddelbuettel Feb 10 '16 at 13:38