1

I'm trying to load a library in an Rscript, but it's giving me a strange error. I'm running the 2.12.1 version of the Rscript binary, yet it complains that my package was built under version 2.12.1. Any idea what's going on here?

    [17:55:13 trash] $ ./tmp.R 
    Loading required package: blah
    Error: (converted from warning) package 'blah' was built under R version 2.12.1


    [17:55:47 trash] $ cat tmp.R 
    #!/path/to/R/2.12.1/bin/Rscript --quiet
    library(blah)
khoda
  • 355
  • 3
  • 7
  • What happens when you run `/path/to/R/2.12.1/bin/Rscript tmp.R?` How about `/path/to/R/2.12.1/bin/R --slave --no-restore tmp.R`? What about `/path/to/R/2.12.1/bin/Rscript --version` and `/path/to/R/2.12.1/bin/R --version`? – Michael Hoffman Oct 28 '11 at 23:01
  • 3
    Similarly, change `library(blah)` to `print(version)` or `print(R.version())` or `print(sessionInfo())`. Path issues are not uncommon. – Iterator Oct 28 '11 at 23:16
  • try `whereis Rscript` and use appropriate path after `#!` – aL3xa Oct 28 '11 at 23:19
  • 1
    @aL3xa That may not be correct if khoda's intentionally using a particular installation (i.e. version) of R that is not the same as the result of `whereis`. – Iterator Oct 29 '11 at 01:43
  • 1
    Michael, I get the same errors if I try your first two suggestions. When I run the next two suggestions, I get 2.12.1 for both. Iterator, the strange this is that even though /../Rscript --version gives me 2.12.1, if I do print(version), I get 2.7.2. How could that be?! – khoda Oct 31 '11 at 18:03

1 Answers1

4

I figured it out with help from comments by @aL3xa and @Iterator. When I run whereis Rscript, I get:

Rscript: /usr/bin/Rscript /usr/bin/X11/Rscript

None of those represents the R installation I want to use (version 3.2.2 in this case), which would be located at

/myinstall/R-3.2.2/bin/

But if I run the Rscript command with the whole path, I force it to use the desired installation:

/myinstall/R-3.2.2/bin/Rscript tmp.R

which runs like a breeze.