Rscript pointing to incorrect R version in local build - r

I recently installed a local version of R 3.1.0 on a Linux Redhat server as follows:
# from R-3.1.0 directory
./configure --prefix=$(pwd)
make
make install
In addition, I've updated PATH and R_LIBS in my .bashrc. If I run path/to/local/R/bin/Rscript --version, then it returns the proper version number. However, if I give it a test script that prints sessionInfo it yields information from the system-wide R installation.
Is there any more I need to do to run the local version of R using Rscript? From reading a similar issue here, it looks like the code above should be all that's necessary. There's a similar SO issue here, but it's unresolved.
Edit:
I just fired up Ubuntu in a VM and was able to install R locally and run Rscript without problem (using the same commands listed above). Have I gone crazy? Is there anything that might be floating around the Redhat environment on this server that might mess up the installation? Sanity checks?

Related

Difficulty Running Multiple Versions of R from Command Line

I'm in a team that is running multiple cronjobs that call R scripts from a remote machine (macos). My colleague needs to run 3.6 for a new script, while a package that is essential to mine has not been updated for it yet. I'm trying to put multiple installations on the same computer so we just specify which "R" version to call in the cronjob.
I know installing from source isn't recommended on macos, so I've been trying to follow the directions here https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Multiple-versions and ran the pkgutil --forget commands to prevent the R 3.6 installation from overwriting the R.framework/Versions/3.5 directory.
Here are the pkgutil commands that I ran:
sudo pkgutil --forget org.r-project.x86_64.tcltk.x11
sudo pkgutil --forget org.r-project.R.el-capitan.GUI.pkg
sudo pkgutil --forget org.r-project.R.el-capitan.fw.pkg
sudo pkgutil --forget org.r-project.x86_64.texinfo
Yet after installing 3.6 from CRAN, when I run the following line:
Library/Frameworks/R.framework/Versions/3.5/Resources/bin/R
Instead of the 3.5.3 console running in the terminal, the 3.6 console pops up.
I'm confused with what to do here - I've also used
ls -la 3.5/Resources/bin | grep "/->"
to check and see if a symlink was created during the install that would change the version/location but get no results, and when I run Rscript --version in the same directory as the R path shown above, I get the following output:
R scripting front-end version 3.5.3 (2019-03-11)
Though when I try to run my script using this location of Rscript I get the same error that I did when running it using R 3.6. However, once I reinstalled R 3.5.3 the script ran fine.
Basically, I think somehow the most recently installed version of R seems to override and run no matter what I do to try and insure that an older version runs instead. Can someone help me piece together how or why this is happening, or provide a suggestion as to how to install R 3.6 as the default "R" while still allowing me to run 3.5.3 for certain scripts as needed?
I have similar problem. What you observed is clearly mentioned on https://cran.rstudio.org/doc/manuals/R-admin.html#Uninstalling-under-macOS: "However, R.APP will always run the ‘current’ version, that is the last installed version.". So far, I don't know how to solve the problem either. Using Rswitch worked very well to switch R versions manually, but i don't know how to integrate Rswitch to command lines.

Rscript calling different R version

I have read this post and this post and this post but the solutions there (most notably, using the full path to Rscript) have not resolved my problem:
I have installed the latest R on a server in my local directory (because the system wide R is out of date), and added this directory to the PATH environment variable in .bashrc. From the command line I get the following:
$ R --version
R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
And
$ Rscript --version
R scripting front-end version 3.4.3 (2017-11-30)
Which is what I expect. However, if I have the following script (named test.r):
#!/path/to/my/local/bin/Rscript
sessionInfo()$R.version$version.string
I get this:
$ ./test.r
[1] "R version 3.3.2 (2016-10-31)"
Which is a different version.
(On a related note, when I use the parallel and doParallel libraries, it is apparent that the spawned processes are also using the older version of R. I suspect the root of these issues is the same.)
It seems to me that .bashrc is not the right place to set the PATH for this scenario. What is the right way to do this?
Thanks in advance!
EDIT
This scenario arose on an HPC cluster, and I found that module unload R removed the older version of R from my environment. However, even with the old R module loaded, my local version was still first in my PATH, as set by .bashrc. So the environment in which R is getting called by Rscript (or by #!/usr/bin/env Rscript, for that matter) must not be looking in my .bashrc. This is not a shock to me, but I still do not know The Right Way™ to set the PATH so the above works As Expected™.

Installing R on Apache Zeppelin

I'm trying to install Apache Zeppelin on my old computer that runs Ubuntu. So far, I'm able to install Zeppelin very easily by cloning the latest 0.6.0 snapshot release using
git clone https://github.com/apache/incubator-zeppelin.git
cd incubator-zeppelin
mvn clean package -DskipTests
but I want to have R on Zeppelin. Supposedly, the 0.6.0 snapshot has two R interpreters, but when I run the R tutorial (the pre-made note that uses %r), I get this list of errors.
I followed several guides to try and install R as an interpreter, but each one resulted in some kind of error. I tried this instructional:
http://www.r-bloggers.com/interactive-data-science-with-r-in-apache-zeppelin-notebook/, and got a build failure on "R Interpreter". The error message was
"dependency 'evaluate' is not available for package 'rzeppelin'
* removing '/home/rebecca/Zeppelin-With-R/R/lib/rzeppelin'"
and then a bit lower down
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default) on project zeppelin-zrinterpreter: Command execution failed. Process exited with an error: 1
I also tried this Stack Overflow guide: Anyone tried to add R interpreter onto Apache Zeppelin?, and while I was able to run incubator-zeppelin, I received an error when I used either the %spark.r or %r interpreter tags, saying both "interpreter not found" and "prefix not found". Spark doesn't work either after following the first solution, getting the same error mentioned in the second solution (the jar file not being there), and then trying the second solution.
Does anyone have a guide for installing R onto the newest version of Zeppelin? I'm very flexible in the way I can install it. I can run other operating systems onto my computer, and I also have Virtual Box installed on my other computer, which is a mac.
There is currently a bug in the latest HEAD of zeppelin that was recently introduced and prevents the R interpreter from launching cleanly
Did anyone created a Zeppelin Jira Issue for that?
For me it is working on Zeppelin branch-0.6
build Zeppelin with r profile: -DskipTests -Prthis will...
create a directory 'R' in git repo root
copy the 'zeppelin-rinterpreter*.jar' into git_repo_root/interpreter/spark
build Zeppelin with build distro profile: e.g. -DskipTests -Pbuild-distr -Pspark-1.6 -Phadoop-2.6
use zeppelin-distribution/target/zeppelin*.tar.gz for installation
ensure both 1.1 and 1.2 are present in your zeppelin installation
The error you're getting is that you need to have the R package evaluate installed. You can install this simply by launching R and typing install.packages('evaluate').
That said, your excerpt mentions the directory Zeppelin-with-R. That's my repo, which is the R interpreter in the form when it was accepted into Zeppelin. That is version 0.5.6, not 0.6.0. There is currently a bug in the latest HEAD of zeppelin that was recently introduced and prevents the R interpreter from launching cleanly. Your best bet for now is to use the one from my repo and install clean, without trying to pull-in from Zeppelin HEAD.

Compile an older R version and switch between versions in Ubuntu and RStudio

I just made the switch from Windows to Ubuntu. In windows I had the possibility to change the R version used in Rstudio IDE with Tools -> Global options -> R versions.
This is not possible in Ubuntu in the same way, indeed the R versions menu does not appear in Ubuntu version of RStudio (why??). Could you help me in finding the good solution for switching among different, already installed versions of R, in Ubuntu?
The switch among different versions is important for satisfying packages modifications and making old scripts working.
I apologize was not a great question, but more of the kind: "please help me, I'm desperate, I've loose all my Windows habs!" ;)
So if anyone like me want to make the switch from Windows to Ubuntu here is how you can compile an older R version and switch between versions using RStudio. As already #Andrie commented out here are some informations, however not complete https://support.rstudio.com/hc/en-us/articles/200486138-Using-Different-Versions-of-R.
You already have the R version provided by Ubuntu Software Center or a more recent version but you need an older version to run an old important script?
First you need to compile the desired R version from source. In Ubuntu updating R to a newer version leave you with one only version (the updated ones) and not two the older and the new like in Win.
Let's go to the shell and install all you need to build R from source
sudo apt-get build-dep r-base
to install all libraries you will need for compiling. (look also here http://cran.us.r-project.org/bin/linux/ubuntu/)
Download the version you need on CRAN
/bin/linux/ubuntu/MyUbuntu(trusty,precise,lucid) The archive you
need is something like:
r-base_TheVersionIWant.orig.tar.gz
Extract it in a directory (maybe ~/R)
then (in the shell) enter the top directory of the unpacked archive
then you can read the INSTALL file, and run configure with the --enable-R-shlib option (otherwise you will not be able once compiled to run it in RStudio)
./configure --enable-R-shlib && make
then following the INSTALL file
make check
make pdf
make info
If all was ok, you can tell R studio where find the bin/R file it needs
export RSTUDIO_WHICH_R= myPahtTo/bin/R
and fire rstudio with
rstudio
You have an RStudio version running the desired R Version.
When you will close the terminal and the rstudio session you will come back to the system default version of R. Then repeat just the last two lines to come back when you want.

qpdf.exe for compactPDF?

I am trying to check a package that I have built (with vignette) using R CMD check --as-cran [my package] in my windows command prompt. All goes well until I get the message,
WARNING 'qpdf' is needed for checks on size reduction of PDFs
I have downloaded qpdf, put the unzipped folder in my program files directory, and added the bin folder to the PATH.
Not quite sure what else I need to do? I have the feeling I have not installed qpdf correctly or I need to build this program itself? I have read through the readme files and manual for qpdf which appear to be more aimed at unix users (which I have no experience with... I am your standard/regular windows user with little to no programming experience outside of statistical languages). I have had a go at trying to build qpdf using cgywin, but ended up failing to install zlib and prec. Any tips?
I would try
Sys.which(Sys.getenv("R_QPDF", "qpdf"))
Sys.getenv("PATH")
to establish that R is really not finding the qpdf executable, and see where it is looking. You probably shouldn't need to rebuild everything, just figure out why R is not finding the qpdf executable ... does running qpdf from a terminal window work ... ? How are you starting R, and did it have a chance to get the new PATH definition (i.e. do you need to open a new terminal window, or ?? reboot ??)
The incantation above was extracted from tools::compactPDF, from the default value of the qpdf argument, on a Linux machine. You should check for yourself, in case (e.g.) the Windows version is looking for qpdf.exe rather than qpdf ...
There are a couple of other things to consider on a Windows machine:
If you are running the 32-bit version of R, it is important that you download the 32-bit version of qpdf, which is the version linked from the SourceForge homepage. If you are running a 64-bit installation of R, you will need to do a bit of digging to locate the 64-bit version of qpdf, which is buried a little more deeply (version 7.0 is listed here).
Once you have extracted the zipped qpdf directory to your hard disk, perhaps under C:\Program Files\, added C:\Program Files\qpdf-version_number\bin to your system PATH under the environment variables, and re-launched R, Windows needs to establish that pqdf is safe to run.
Navigate to C:\Program Files\qpdf-version_numer\bin and execute qpdf.exe (by double-clicking). Windows 10 throws up a security warning, as it's an unrecognized executable file. You'll need to use the more options link to find the button to run the program. This done, Windows will recognize the file as safe to run and allow other software, including R, to use it.
Recent developments: If you install Rtools 3.5 qpdf is included and that warning is gone. Rtools is a toolset for building packages on Windows and is recently reworked by Jeroen Ooms.
More information : https://cran.r-project.org/bin/windows/Rtools/
Note that the changelog is incomplete, as Rtools 3.5 isn't frozen yet at the time of writing (2019-03-01). Even though it's not visible on the page yet, qpdf.exe is included in the bin directory after installation.
After installing the latest version of RTools, the warning still popped up.
However, I noticed that the Windows "where" command gave two paths to qpdf (different versions). After removing the R_QPDF environment variable and removing the new install of qpdf from the Windows path, so that only qpdf in RTools was found, the warning disappeared.
I got the same warning on Ubuntu so here's a Ubuntu solution for completeness:
First update packages
sudo apt update
Then install qpdf with
sudo apt install qpdf
Tested on Ubuntu 20.04.

Resources