Everywhere All articles Download Buy — $19

Where apps hide your files

R's library folders: system, personal and renv

Updated 2026-10-28 · 6 min read

R keeps packages in a system library inside /Library/Frameworks/R.framework and a personal one under ~/Library/R, and .libPaths() shows which it is using. This page covers both, plus renv's cache and what happens to your packages when you upgrade R.

Ask R first

R can tell you exactly where it looks. In R.app, RStudio or Terminal, run:

.libPaths()

It prints the library folders in the order R searches them. With CRAN's installer on an Apple silicon Mac, these are the two places (shown for R 4.6):

~/Library/R/arm64/4.6/library
/Library/Frameworks/R.framework/Resources/library

The personal folder (the first line) is listed only once it exists, and by default it does not, so many Macs show just the system library. 4.6 stands for the R version without the patch level, and arm64 becomes x86_64 on an Intel build of R. Both forms come from CRAN's own documentation.

The two folders

The system library lives inside the R framework. CRAN's macOS FAQ calls /Library/Frameworks/R.framework/Resources/library the main library: it holds the packages that ship with R (base and the recommended set), and only administrators can install into it. That Resources path is a link, which resolves through Versions/Current to a versioned folder. R's manual gives 4.6, 4.6-x86_64 and 4.5-arm64 as examples of those folder names, so list /Library/Frameworks/R.framework/Versions to see yours.

The personal library is under ~/Library/R. The manual gives ~/Library/R/arm64/4.6/library as an example of the default on a Mac, and the macOS FAQ describes the Intel form as ~/Library/R/x86_64/x.y/library. R only uses this folder once it exists. If it is missing, create it from R, which knows the exact name, then restart R so it joins the search path:

dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE)

R's manual notes that R_LIBS_USER has a default value but it is only used if the directory exists, which by default it does not.

Which folder gets the package

install.packages("ggplot2") installs into the first folder on .libPaths(), according to its help page. If that folder is not writable, R offers to create your personal library and install there instead. CRAN's build lets administrator accounts write to the system library, and the macOS FAQ says R.app's Package Installer defaults to system-wide for admin users and to the personal tree for others, so on a single-user Mac packages often land inside the framework. To force a location:

install.packages("ggplot2", lib = "~/Library/R/arm64/4.6/library")

Each package is a folder named after the package, containing DESCRIPTION, R/, and compiled code under libs/ when it has any.

Other things R keeps

ItemWhere
R.app (the GUI)/Applications/R.app
The R framework/Library/Frameworks/R.framework
R and Rscript commandslinks in /usr/local/bin
Tcl/Tk and Texinfo that the installer adds/opt/R/arm64 (or /opt/R/x86_64)
Your startup files~/.Renviron and ~/.Rprofile (hidden)
Version-wide startup filesRprofile.site and Renviron.site in R.home()/etc
RStudio's settings~/.config/rstudio/rstudio-prefs.json

The R locations come from R's installation manual and the macOS FAQ; the RStudio one from Posit's documentation. To print the framework path for the R you are running, use R.home().

~/.Renviron is where you set R_LIBS_USER if you want packages somewhere else, for example on a larger drive. Posit's RStudio guide describes .Renviron as the file for environment variables such as R_LIBS_USER, read at startup, and also as the usual home for API keys, so treat it as private and never paste it anywhere.

RStudio and renv

RStudio does not keep its own copy of R or your packages. It runs whichever R it finds, and the library paths it shows are the ones .libPaths() reports. If you have more than one R, Posit's guide recommends the rig tool, with rig rstudio 4.3.0 starting RStudio on a chosen version. RStudio's CRAN mirror setting is in Tools > Global Options > Packages.

If a project uses renv, its packages are not in the folders above. Each renv project has its own library inside the project's renv folder. renv keeps its global state, including the package cache shared by all projects, under this root on a Mac:

~/Library/Caches/org.R-project.R/R/renv

Run renv::paths$cache() to print the cache folder itself. Older versions of renv used ~/Library/Application Support/renv, and renv's docs say an existing folder there is still used. RENV_PATHS_ROOT moves the whole root and RENV_PATHS_CACHE just the cache. Project libraries can hold links into the cache, so check with renv's own commands before deleting anything.

After upgrading R

R's manual says CRAN's installer removes any previous R framework of the same CPU type that it finds (pkgutil --forget is the documented way to keep it), so packages that sat in the old system library go with the old framework. Packages in your personal library survive, but a new minor version (4.5 to 4.6, say) reads a new personal folder, so they appear to vanish. Before upgrading, save a list of the packages you added yourself:

ip <- installed.packages()
saveRDS(rownames(ip)[is.na(ip[, "Priority"])], "~/r-packages.rds")

After upgrading, install.packages(readRDS("~/r-packages.rds")) installs them again. If you forgot, ls ~/Library/R/arm64/4.5/library still lists what your old personal library held. Reinstall rather than copying package folders across: CRAN builds binary packages separately for each minor version of R (its repository paths end in the x.y version), so a copied folder may not match the new R.

Freeing space or removing R

Packages are ordinary folders, so removing one is remove.packages("name") from R, which is cleaner than deleting its folder by hand. To uninstall R entirely, CRAN's manual says drag /Applications/R.app and /Library/Frameworks/R.framework to the Trash and remove the R and Rscript links in /usr/local/bin; the optional Tcl/Tk and Texinfo parts in /opt/R are separate. Your personal library under ~/Library/R and your startup files stay until you remove them yourself.

Homebrew's r formula is a separate build with its own library folders, and CRAN's folders above do not apply to it. Run .libPaths() in that R and trust what it prints.

Why a search misses them

~/Library is left out of Finder searches, .Renviron and .Rprofile are hidden dot-files, and the framework sits in /Library/Frameworks. A package's files have generic names such as DESCRIPTION and NAMESPACE, which appear hundreds of times.

Finding a package folder again

Type the package's name, for example ggplot2, into Everywhere and the folders called ggplot2 show their full paths, which tells you at once which R version and which library a copy belongs to. If you type .Rprofile, it finds your startup file. It searches names only, so it cannot say which version a package is; open its DESCRIPTION file for that. Everywhere scans the ~/Library and /Library folders above without extra permission.

Common questions

Where does R install packages on a Mac?

Into the first folder on .libPaths(). With CRAN's installer that is the system library inside /Library/Frameworks/R.framework for an administrator account, or a personal folder such as ~/Library/R/arm64/4.6/library once it exists.

How do I find my R library path?

Run .libPaths() in R or RStudio. It lists every library folder in search order, and R.home() prints the folder of the R you are running.

Why did my R packages disappear after updating R?

Each minor version such as 4.6 reads its own personal library, and CRAN's installer removes the previous framework along with its system library. List the old personal folder or a saved package list, then reinstall those packages under the new R.

Where does renv store packages on a Mac?

Each project has its own library in the project's renv folder, and renv's shared cache sits under ~/Library/Caches/org.R-project.R/R/renv. Run renv::paths$cache() for the exact folder, and set RENV_PATHS_ROOT to move it.

Find any file before you finish typing

Everywhere keeps track of every file on your Mac — including the folders Spotlight hides and drives you have unplugged. Free for a day, then $19 once.

Version 2.20.3 · macOS 13+ · 4.7 MB · notarised

Related

© 2026 Caretopia Network Private Limited Everywhere for Mac Buy a licence Articles Privacy Support