I'm trying to update R from 3.2.2 (Fire safety) to 3.3.1 (Bug in your hair) on MacOS 10.11.15 (El Capitan).
Initially I tried to use the R-3.3.1.pkg from CRAN, which allowed me to use the new version in R.app. However when trying to access R through terminal, and through Sublime REPL, the previous version appears even though the installation should have deleted previous copies of R.
How do I fully delete the old copy? In El Capitan, the Frameworks folder is no longer present, so the previous fix:
rm -rf /Library/Frameworks/R.framework /Applications/R.app \
/usr/bin/R /usr/bin/Rscript
Does not work.
P.S. (meta) how can I fireproof myself against these OS conflicts in future? Should I just run R through a VM?
This was the problem for me.
Anaconda, the python distribution provided by continuum analytics, contains a copy of R for some reason.
Therefore, if you delete your copy of R from CRAN, that (outdated) copy of R will become the default R for use in terminal, sublimeREPL, etc.
In general, booting up R and running R.home() will reveal the installation directory.
Since I want to use R and python, and update them independently, I will stop using Anaconda.
Related
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.
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™.
I have been using ipython notebook to run some R scripts. Now the problem is I have two R versions on my Ubuntu 14.04.
One is R.3.2.2 at /home/MYNAME/anaconda2/bin/R, another one is the R which I need for R studio,
now the problem is I want to only use R.3.3.1 for my system as I need some advanced task to be done.
I use conda uninstall r, after running this, according to the print out, a lot of R related packages is removed, if i run conda uninstall r again, it said
Fetching package metadata .......
Using Anaconda Cloud api site https://api.anaconda.org
Solving package specifications: ..........
Error: no packages found to remove from environment: /home/MyName/anaconda2
but when I run Which R again, still it is the anaconda R, if I run R in the terminal, it is still R3.2.2, anyone knows how could I remove this anaconda R version?
You probably needed to run hash -r in your session (or rehash if using zsh) to update your executables on PATH for the which command. A new terminal session would also fix the problem.
you can try conda uninstall r-base, this will remove R and all of the R-library.
The questions also implies that one cannot use anaconda R with rstudio.
On Linux you can
export RSTUDIO_WHICH_R=/home/USER/anaconda3/bin/R
and add to .profile (d/o your distro) to use rstudio with anaconda R and packages
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.
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?