Search code examples
rmacosrprofile

Rprofile.site not found by R on Startup in macos


Problem

R cannot detect the presence of "Rprofile.site" file in home directory's /etc folder despite it being there.

Investigation

Since the Rprofile.site lives in the home directory as /etc/Rprofile.site. I checked the home directory using R.home(component="home") and got "/Library/Frameworks/R.framework/Resources". Then I created an Rprofile.site in RStudio and put it in the folder. I restarted RStudio but it still wouldn't automatically load the file.

From Efficient R Programming: https://csgillespie.github.io/efficientR/3-3-r-startup.html I tried the following:

site_path = R.home(component = "home")
fname = file.path(site_path, "etc", "Rprofile.site")
file.exists(fname) 

but it yielded False despite the file being in the directory.

I made sure to add an extra line, per yi hui's post: https://yihui.name/en/2018/04/rprofile-trailing-newline/ but it still did not work.

In addition, I followed the recommendation of numerous other SO and RStudio threads to no avail.

References

Getting .Rprofile to Load at Startup

https://community.rstudio.com/t/create-rprofile-automatically-when-creating-new-project/3719

https://support.rstudio.com/hc/en-us/community/posts/200657076-Also-load-the-user-s-Rprofile-when-opening-a-project-with-a-project-specific-Rprofile


Solution

  • Solution

    I right clicked the Rprofile.site file and deleted the .R that still hung on to the actual file. Despite renaming it in Finder, the .R extension was still there and thus was not recognized by R.

    screenshot of problem area