RStudio does not seem to scan standard locations as declared

rstudio

#1

Hello,

I am on macOS High Sierra.

I have installed R-devel as per instructions in the INSTALL file shipped with the snapshot archive.
From the command line, all seems fine:

$ which R
/usr/local/bin/R
$R
R Under development (unstable) (2017-12-07 r73866) -- "Unsuffered Consequences"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.2.0 (64-bit)
[...skipped...]
> R.home()
[1] "/usr/local/lib/R"

However, if I launched RStudio, I still get my ‘old’ R 3.4.2:

R version 3.4.2 (2017-09-28) -- "Short Summer"
> R.home()
[1] "/Library/Frameworks/R.framework/Resources"

This RStudio help page states that:
"RStudio scans for the R executable in the following sequence:

/usr/bin/R
/usr/local/bin/R # <— this one is valid for me!
/opt/local/bin/R

If RStudio is not able to locate R by scanning these locations, it will fall back to using whatever version of R is located at /Library/Frameworks/R.framework/."

In addition the same help page suggests the following trick that did not work for me:

export RSTUDIO_WHICH_R=/usr/local/bin/R
open -a rstudio # same 3.4.2

PS: I have also restarted my computer a few times , with no effect.

Many thanks in advance!


#2

Do you have an R executable at /usr/bin/R? Does moving it out of the way make a difference?

I don’t think environment variables set in a shell session are inherited by processed launched through open, so unfortunately your attempts to set RSTUDIO_WHICH_R won’t work.


#3

Thanks for your reply.

I should have said, I also checked all the paths that RStudio is supposed to scan, and /usr/bin/R doesn’t exist.

Thanks for the note about ‘open’

Looking forward to further advice.

Kévin

Envoyé de mon iPhone


#4

One other thing to check: On macOS, RStudio uses the file at /etc/paths to decide where to look for R, scanning the paths in that file from top to bottom. For example, the contents of mine are:

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

I’d be helpful to double-check whether that’s true for you as well.

For what it’s worth, I think you’re doing the right thing – on my own machine, I have an R-devel installation that I activate by updating the R symlink at /usr/local/bin/R.

Can you also confirm the output of which R | xargs readlink? For example, I see:

$ which R | xargs readlink
/Library/Frameworks/R.framework/Resources/bin/R

Finally, it might be helpful to see what the PATH is in your launched RStudio session, and the version of R found on the PATH. For example, I have:

> Sys.which("R")
                 R 
"/usr/local/bin/R" 
> Sys.getenv("PATH")
[1] "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands"

#5

Hi,

Thanks for following up on this. Much appreciated.

The weirdest thing is that on an older MacBook Pro set up pretty much the same way, I have R under development 2017-09-11 running just fine. It’s on a more recent iMac that I’m currently facing the problem, if that’s any relevant.

Here is the content of my /etc/paths (identical to yours)

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

Now, the weirdest part my RStudio:

R version 3.4.2 (2017-09-28) -- "Short Summer"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> Sys.which("R")
                 R 
"/usr/local/bin/R" 
> Sys.getenv("PATH")
[1] "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin:/opt/X11/bin"

while my terminal:

$ /usr/local/bin/R

R Under development (unstable) (2017-12-07 r73866) -- "Unsuffered Consequences"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.2.0 (64-bit)
[truncated]

Also, I should probably add:

$ ls -l /Library/Frameworks/R.framework/Versions/
total 0
drwxrwxr-x  6 root  admin  192 30 Oct 10:40 3.4
lrwxr-xr-x  1 root  admin    3 30 Oct 10:40 Current -> 3.4

… What on Earth is going on ?


#6

Hi again,

While I can’t explain the issue I’ve described so far (re: installation from source).
I have finally come across this page: https://r.research.att.com/#other
that offers, among others, an installer package for R-devel 3.5.0:

R-devel
3.5.0 Under development (unstable)
(2017/12/11, r73889)

After using the ‘double-click installer’ (as oppose to the compilation from source I previously did), I have now:

$ ls -l /Library/Frameworks/R.framework/Versions/
total 0
drwxrwxr-x  3 root  admin   96 12 Dec 09:29 3.4
drwxrwxr-x  6 root  admin  192 12 Dec 09:29 3.5
lrwxr-xr-x  1 root  admin    3 12 Dec 09:29 Current -> 3.5

Nevertheless, I would still like to keep this thread open until the following puzzle is answered:
After the installation above, when I open RStudio, why do I see:

R Under development (unstable) (2017-12-11 r73889) -- "Unsuffered Consequences"
[...]
> Sys.which("R")
                 R 
"/usr/local/bin/R"
> Sys.getenv("PATH")
[1] "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin:/opt/X11/bin"

which means that it is now using the ‘double-click-installed’ R in /Library/Frameworks/R.framework/ (based on the date of the snapshot), while both Sys.which and Sys.getenv indicate that it should be using the /usr/local/bin/R.

Actually, I may have a hint of what’s happening, following the ‘double-click installer’

$ /usr/local/bin/R
R Under development (unstable) (2017-12-11 r73889) -- "Unsuffered Consequences"
$ ls -lh /usr/local/bin/R*
lrwxr-xr-x  1 root  admin    53B 12 Dec 09:29 /usr/local/bin/Rscript -> /Library/Frameworks/R.framework/Resources/bin/Rscript
lrwxr-xr-x  1 root  admin    47B 12 Dec 09:29 /usr/local/bin/R -> /Library/Frameworks/R.framework/Resources/bin/R

Note that the sources from which I compiled /usr/local/bin/R are marked:

$ less SVN-REVISION
Revision: 73866
Last Changed Date: 2017-12-07

My guess is my make install didn’t create some links to help RStudio detect the /usr/local/bin/R that I compiled from source (2017-12-07)