How can the R location be customized for RStudio

How can the R location be customized for RStudio

I previously used homebrew to install R and the package installer for RStudio. Recently I started using Boxen, which takes over homebrew. I had to re-install R from source using homebrew, and it now exists in my Boxen Cellar location. Now RStudio no longer launches, saying “Unable to locate R binary by scanning standard locations”. I tried reinstalling RStudio (I needed to upgrade anyway) but that didn’t help. It doesn’t even open for long enough to let you specify a custom location.

Answer #1:

OK I figured it out finally. Discovered from this post that you can set RSTUDIO_WHICH_R to your custom location. On Mountain Lion, this is most easily done with:

For OS X Mountain Lion 10.8:

echo setenv RSTUDIO_WHICH_R [your custom bin path]/R | launchctl

Another option is to set a softlink from /usr/local/bin to the custom R path, but the above seems like a better solution.


Edit: For newer macOS versions:

launchctl setenv RSTUDIO_WHICH_R [your custom bin path]/R

But after a restart launchctl has forgotten the environment variable again.
Therefore a LaunchAgent-.plist for launchctl must be created.
Instructions could be found here.

Answer #2:

I ended up deleting the alias file “R” from /usr/bin/ In this way, I don’t have to set the RStudio environment variable every time. From www.rstudio.com/ide/docs/advanced/versions_of_r

Rstudio looks first in /usr/bin/R and then on /usr/local/bin/R, where I have the new version of R installed.

Read more here: Source link