Learn R Programming

courieR (version 0.2.2)

find_routes: Detect R installations on the system

Description

Scans the current machine for every R installation it can find, across multiple sources per platform, and returns a tidy data frame of results.

Usage

find_routes(search_paths = NULL)

Value

A data frame with one row per unique R installation and the following columns:

version

Character. R version string, e.g. "4.4.1".

rscript_path

Character. Absolute path to the Rscript executable.

is_current

Logical. TRUE for the R session running courieR.

Arguments

search_paths

An optional character vector of additional paths to search. Each element may be a directory containing bin/Rscript (or bin/x64/Rscript.exe on Windows), or a direct path to an Rscript executable.

Details

Detection sources by platform:

Windows

  • HKLM registry (SOFTWARE\R-core\R) — standard admin installs via the CRAN Windows installer.

  • HKCU registry (SOFTWARE\R-core\R) — non-admin installs that register under the current user hive only.

  • %ProgramFiles%\R — directory scan for admin installs not in the registry.

  • %LOCALAPPDATA%\Programs\R — rig-managed and other user-local installs.

  • %USERPROFILE%\Documents\R — installs placed in the user's Documents folder.

  • rig (rig list) — any additional versions managed by rig that were not found by path scanning.

macOS

  • /Library/Frameworks/R.framework/Versions — system-wide CRAN installer.

  • ~/Library/Frameworks/R.framework/Versions — user-local framework installs (no admin required).

  • Homebrew: /opt/homebrew/opt/r (Apple Silicon) and /usr/local/opt/r (Intel).

  • rig (rig list) — rig-managed versions.

Linux

  • /opt/R — rig system-wide installs.

  • ~/.local/share/rig/R — rig user-local installs.

  • conda environments (active $CONDA_PREFIX).

  • System Rscript on $PATH.

Symlinks are resolved via fs::path_real() so that duplicate entries from different detection sources pointing to the same executable are collapsed.

Examples

Run this code
# \donttest{
routes <- find_routes()
routes[, c("version", "rscript_path", "is_current")]

# include a non-standard install
routes <- find_routes(search_paths = "/opt/custom-r/bin/Rscript")
# }

Run the code above in your browser using DataLab