Skip to content
Prev 10823 / 15075 Next

Failure of CLI with .Rprofile on Mac OS X

I suspected that I needed to put "more or less standard" in my reply...

Anyways, I think PWD is a red herring. Unless I'm confused (which has happened), the CLI on OS X is governed by src/unix/sys-unix.c and that has

attribute_hidden
FILE *R_OpenInitFile(void)
{
    char buf[PATH_MAX], *home, *p = getenv("R_PROFILE_USER");
    FILE *fp;

    fp = NULL;
    if (LoadInitFile) {
        if(p) {
            if(!*p) return NULL;  /* set to "" */
            return R_fopen(R_ExpandFileName(p), "r");
        }
        if((fp = R_fopen(".Rprofile", "r")))
            return fp;
        if((home = getenv("HOME")) == NULL)
            return NULL;
        snprintf(buf, PATH_MAX, "%s/.Rprofile", home);
        if((fp = R_fopen(buf, "r")))
            return fp;
    }
    return fp;
}

and $PWD doesn't factor into this. $HOME does, though. I can see three ways in which $HOME/.Rprofile might drop off the radar:

1) HOME set incorrectly
2) $HOME or $HOME/.Rprofile not readable according to permissions and ownership of R binary
3) path length overflow 

Neither seem particularly likely to me, but they should be relatively easy to check. (PATH_MAX on OS X seems to be 1024).

Something in the style of (NB, this zaps an existing ~/.Rprofile if you copy it literally)

$ echo 'Rprofile <- TRUE' >  ~/.Rprofile
$ R
...
[1] TRUE
-pd
On 21 Sep 2014, at 11:02 , Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote: