Skip to contents

Convenience function that seeks to install pre-built binary libraries used on CRAN for macOS through the recipes system designed by Simon Urbanek.

Usage

recipes_binary_install(
  pkgs,
  url = "https://mac.R-project.org/bin",
  os = tolower(paste0(system("uname -s", intern = TRUE), gsub("\\..*", "",
    system("uname -r", intern = TRUE)))),
  arch = system("uname -m", intern = TRUE),
  os.arch = "auto",
  dependencies = TRUE,
  action = c("install", "list"),
  sudo = TRUE,
  password = NULL,
  verbose = TRUE
)

Arguments

pkgs

Character vector of binary names to install, "all" for all binaries, or "r-base-dev" for R binaries.

url

URL of the repository root. Default https://mac.R-project.org/bin

os

Name and version of the OS, e.g. "darwin22" where "darwin" refers to macOS and 22 is the kernel version number.

arch

The architecture of either arm64 (M1/M2/M3) or x86_64 (Intel). This is only used if os.arch="auto".

os.arch

Either name of the repository such as "darwin20/arm64", "darwin20/x86_64", "darwin17/x86_64", or "auto". Default "auto".

dependencies

Install build dependencies (TRUE) or only the requested packages (FALSE). Default TRUE.

action

Determine if the binary should be downloaded and installed ("install") or displayed ("list"). Default "install" to download and install the binaries.

sudo

Attempt to install the binaries using sudo permissions. Default TRUE.

password

User password to switch into the sudo user. Default NULL.

verbose

Describe the steps being taken. Default TRUE

Details

The function attempts to detect the appropriate repository and installation path for the binary packages when "auto" is set. By default, the repository and the install path are either:

NameInstallation LocationTarget
darwin17/x86_64/usr/localmacOS 10.13, Intel (x86_64)
darwin20/x86_64/opt/R/x86_64macOS 11, Intel (x86_64)
darwin20/arm64/opt/R/arm64macOS 11, Apple M1 (arm64)

Author

Simon Urbanek wrote the function and made it available at https://mac.r-project.org/bin/

James Joseph Balamuta packaged the function and added the option to use sudo on the command line.

Examples

# Perform a dry-run to see the required development packages.
recipes_binary_install("r-base-dev", action = "list")
#> Downloading https://mac.R-project.org/bin/REPOS ...
#> Using repository  https://mac.R-project.org/bin/darwin20/arm64 ...
#> Downloading index  https://mac.R-project.org/bin/darwin20/arm64/PACKAGES ...
#>  [1] "https://mac.R-project.org/bin/darwin20/arm64/xz-5.6.2-darwin.20-arm64.tar.xz"         
#>  [2] "https://mac.R-project.org/bin/darwin20/arm64/tiff-4.5.0-darwin.20-arm64.tar.xz"       
#>  [3] "https://mac.R-project.org/bin/darwin20/arm64/libpng-1.6.43-darwin.20-arm64.tar.xz"    
#>  [4] "https://mac.R-project.org/bin/darwin20/arm64/openssl-3.2.2-darwin.20-arm64.tar.xz"    
#>  [5] "https://mac.R-project.org/bin/darwin20/arm64/jpeg-9e-darwin.20-arm64.tar.xz"          
#>  [6] "https://mac.R-project.org/bin/darwin20/arm64/pcre2-10.42-darwin.20-arm64.tar.xz"      
#>  [7] "https://mac.R-project.org/bin/darwin20/arm64/cairo-1.17.6-darwin.20-arm64.tar.xz"     
#>  [8] "https://mac.R-project.org/bin/darwin20/arm64/texinfo-7.1-darwin.20-arm64.tar.xz"      
#>  [9] "https://mac.R-project.org/bin/darwin20/arm64/libwebp-1.4.0-darwin.20-arm64.tar.xz"    
#> [10] "https://mac.R-project.org/bin/darwin20/arm64/pkgconfig-0.29.2-darwin.20-arm64.tar.xz" 
#> [11] "https://mac.R-project.org/bin/darwin20/arm64/freetype-2.13.2-darwin.20-arm64.tar.xz"  
#> [12] "https://mac.R-project.org/bin/darwin20/arm64/fontconfig-2.14.2-darwin.20-arm64.tar.xz"
#> [13] "https://mac.R-project.org/bin/darwin20/arm64/pixman-0.42.2-darwin.20-arm64.tar.xz"    
#> [14] "https://mac.R-project.org/bin/darwin20/arm64/zlib-stub-0.1-darwin.20-arm64.tar.xz"    
#> [15] "https://mac.R-project.org/bin/darwin20/arm64/harfbuzz-8.5.0-darwin.20-arm64.tar.xz"   
#> [16] "https://mac.R-project.org/bin/darwin20/arm64/expat-2.6.2-darwin.20-arm64.tar.xz"      
#> [17] "https://mac.R-project.org/bin/darwin20/arm64/icu-71.1-darwin.20-arm64.tar.xz"         
#> [18] "https://mac.R-project.org/bin/darwin20/arm64/fribidi-1.0.15-darwin.20-arm64.tar.xz"   

if (FALSE) { # \dontrun{
# Install the mandatory library binaries for building R on macOS using sudo
recipes_binary_install("r-base-dev", sudo = TRUE)
} # }