4

The binary of Rscript is available but when I try to use it I get:

Rscript helloworld.r

Rscript execution error: No such file or directory

If I just do Rscript, it brings the help/usage for it through.

R CMD BATCH is working fine.

I tried adding shebang lines in the R code at the start but it didn't work.

#!/sys_apps_01/R/R-3.2.0/bin/R

#!/sys_apps_01/R/R-3.2.0/bin/Rscript

Sourabh Potnis
  • 1,431
  • 1
  • 17
  • 26

4 Answers4

3

As in your case, this was caused by me moving R (in order to try to use it in an AWS lambda function).

I resorted to doing the equivalent call on R itself:

./R --slave --no-restore --file=TheScript.R
Mark Adamson
  • 878
  • 10
  • 17
2

It's likely this was installed to (configured for) another directory and then moved after installation. Afterwards Rscript won't be able to find the (hardcoded?) R binary. I just had the same problem, which could be solved by reinstalling R.

Andreas

Andreas
  • 716
  • 4
  • 14
0

I preface this solution issuing a caution to do this at one's own risk. However I encountered the same issue and had the following solution:

Say you've run make && make install which has installed R to /path/to/install/loc. Once you've moved this to path/to/new/loc, R/Rscript will then complain it can't find the right file/directory.

Editing the R and Rscript executables in path/to/new/loc/bin, you can change any reference to /path/to/old/loc to /path/to/new/loc. This has worked for me and haven't encountered any further issues

As has been previously mentioned, it's definitely preferable to install R to the required location either through prefix=... in the configure script, or by using the rhome=... argument following make install

Chesster
  • 13
  • 5
  • Are you sure this is working I see Rscript being $ file /opt/third/R/4.0.0/bin/Rscript /opt/third/R/4.0.0/bin/Rscript: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs) how do you "change reference" ? – statquant May 19 '20 at 12:18
0

I encountered the same issue. What happened in my case was that, R was first installed at /usr/lib/R with deb packages, then I moved the dir to /opt/R and defined R_HOME to the new dir, hoping R will adapt to it automatically, but turns out there are hardcoded paths of /usr/lib/R in bin/R. Unless I update the paths, simply moving R to another location will break the installation.

Dagang
  • 24,586
  • 26
  • 88
  • 133