Skip to content

Require

Installing and Loading R Packages for Reproducible Workflows

v2.0.0 · May 15, 2026 · GPL-3

Description

A single key function, 'Require' that makes rerun-tolerant versions of 'install.packages' and 'require' for CRAN packages, packages no longer on CRAN (i.e., archived), specific versions of packages, and GitHub packages. This approach is developed to create reproducible workflows that are flexible and fast enough to use while in development stages, while able to build snapshots once a stable package collection is found. As with other functions in a reproducible workflow, this package emphasizes functions that return the same result whether it is the first or subsequent times running the function, with subsequent times being sufficiently fast that they can be run every time without undue waiting burden on the user or developer.

Downloads

1.5K

Last 30 days

3061st

5.7K

Last 90 days

13.6K

Last year

Trend: -35.3% (30d vs prior 30d)

CRAN Check Status

4 ERROR
9 OK
Show all 13 flavors
Flavor Status
r-devel-linux-x86_64-debian-clang OK
r-devel-linux-x86_64-debian-gcc OK
r-devel-linux-x86_64-fedora-clang OK
r-devel-linux-x86_64-fedora-gcc OK
r-devel-windows-x86_64 OK
r-oldrel-macos-arm64 ERROR
r-oldrel-macos-x86_64 ERROR
r-oldrel-windows-x86_64 OK
r-patched-linux-x86_64 OK
r-release-linux-x86_64 OK
r-release-macos-arm64 ERROR
r-release-macos-x86_64 ERROR
r-release-windows-x86_64 OK
Check details (4 non-OK)
ERROR r-oldrel-macos-arm64

tests

Running ‘testthat.R’ [3s/4s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > # Point pak's pkgcache at a per-session writable cache BEFORE library(Require)
  > # loads pak. Under R CMD check (CRAN policy), pkgcache aborts if R_USER_CACHE_DIR
  > # is unset; without this every Require::Install() inside the test suite errors
  > # with "Please install pak" because pak's namespace fails to load.
  > if (!nzchar(Sys.getenv("R_USER_CACHE_DIR"))) {
  +   .ucd <- tempfile("RequireUserCache_")
  +   dir.create(.ucd, recursive = TRUE, showWarnings = FALSE)
  +   Sys.setenv(R_USER_CACHE_DIR = .ucd)
  +   rm(.ucd)
  + }
  > 
  > library(Require)
  > library(testthat)
  
  Attaching package: 'testthat'
  
  The following object is masked from 'package:Require':
  
      setup
  
  > test_check("Require")
  Saving _problems/test-00pkgSnapshot_testthat-2.R
  Saving _problems/test-02extract_testthat-3.R
  Saving _problems/test-03helpers_testthat-3.R
  Saving _problems/test-08modu
...[truncated]...
cted`: "data.table@1.18.4"
  
  installed data.table must be pinned to its installed version
  ── Failure ('test-17usePak.R:1485:3'): pinInstalledForPak skips user-version-constrained packages ──
  Expected `grepl("^data.table@", out[2])` to be TRUE.
  Differences:
  `actual`:   FALSE
  `expected`: TRUE 
  
  bare user packages with no constraint must be pinned to installed version to keep deps stable
  ── Error ('test-19smallSnapshot_testthat.R:2:3'): small snapshot install pins each package to the requested version ──
  Error: Please install pak (loadNamespace('pak') failed: there is no package called 'pak')
  Backtrace:
      ▆
   1. └─Require:::setupTest() at test-19smallSnapshot_testthat.R:2:3
   2.   └─Require::Install(c("curl", "httr", "waldo")) at ./helper_0.R:25:3
   3.     └─Require::Require(...)
   4.       ├─base::withCallingHandlers(...)
   5.       └─Require:::pakDepsToPkgDT(...)
  
  [ FAIL 16 | WARN 0 | SKIP 31 | PASS 374 ]
  Error:
  ! Test failures.
  Execution halted
ERROR r-oldrel-macos-x86_64

tests

Running ‘testthat.R’ [7s/13s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > # Point pak's pkgcache at a per-session writable cache BEFORE library(Require)
  > # loads pak. Under R CMD check (CRAN policy), pkgcache aborts if R_USER_CACHE_DIR
  > # is unset; without this every Require::Install() inside the test suite errors
  > # with "Please install pak" because pak's namespace fails to load.
  > if (!nzchar(Sys.getenv("R_USER_CACHE_DIR"))) {
  +   .ucd <- tempfile("RequireUserCache_")
  +   dir.create(.ucd, recursive = TRUE, showWarnings = FALSE)
  +   Sys.setenv(R_USER_CACHE_DIR = .ucd)
  +   rm(.ucd)
  + }
  > 
  > library(Require)
  > library(testthat)
  
  Attaching package: 'testthat'
  
  The following object is masked from 'package:Require':
  
      setup
  
  > test_check("Require")
  Saving _problems/test-00pkgSnapshot_testthat-2.R
  Saving _problems/test-02extract_testthat-3.R
  Saving _problems/test-03helpers_testthat-3.R
  Saving _problems/test-08mod
...[truncated]...
cted`: "data.table@1.18.4"
  
  installed data.table must be pinned to its installed version
  ── Failure ('test-17usePak.R:1485:3'): pinInstalledForPak skips user-version-constrained packages ──
  Expected `grepl("^data.table@", out[2])` to be TRUE.
  Differences:
  `actual`:   FALSE
  `expected`: TRUE 
  
  bare user packages with no constraint must be pinned to installed version to keep deps stable
  ── Error ('test-19smallSnapshot_testthat.R:2:3'): small snapshot install pins each package to the requested version ──
  Error: Please install pak (loadNamespace('pak') failed: there is no package called 'pak')
  Backtrace:
      ▆
   1. └─Require:::setupTest() at test-19smallSnapshot_testthat.R:2:3
   2.   └─Require::Install(c("curl", "httr", "waldo")) at ./helper_0.R:25:3
   3.     └─Require::Require(...)
   4.       ├─base::withCallingHandlers(...)
   5.       └─Require:::pakDepsToPkgDT(...)
  
  [ FAIL 16 | WARN 0 | SKIP 31 | PASS 374 ]
  Error:
  ! Test failures.
  Execution halted
ERROR r-release-macos-arm64

tests

Running ‘testthat.R’ [3s/7s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > # Point pak's pkgcache at a per-session writable cache BEFORE library(Require)
  > # loads pak. Under R CMD check (CRAN policy), pkgcache aborts if R_USER_CACHE_DIR
  > # is unset; without this every Require::Install() inside the test suite errors
  > # with "Please install pak" because pak's namespace fails to load.
  > if (!nzchar(Sys.getenv("R_USER_CACHE_DIR"))) {
  +   .ucd <- tempfile("RequireUserCache_")
  +   dir.create(.ucd, recursive = TRUE, showWarnings = FALSE)
  +   Sys.setenv(R_USER_CACHE_DIR = .ucd)
  +   rm(.ucd)
  + }
  > 
  > library(Require)
  > library(testthat)
  
  Attaching package: 'testthat'
  
  The following object is masked from 'package:Require':
  
      setup
  
  > test_check("Require")
  Saving _problems/test-00pkgSnapshot_testthat-2.R
  Saving _problems/test-02extract_testthat-3.R
  Saving _problems/test-03helpers_testthat-3.R
  Saving _problems/test-08modu
...[truncated]...
cted`: "data.table@1.18.4"
  
  installed data.table must be pinned to its installed version
  ── Failure ('test-17usePak.R:1485:3'): pinInstalledForPak skips user-version-constrained packages ──
  Expected `grepl("^data.table@", out[2])` to be TRUE.
  Differences:
  `actual`:   FALSE
  `expected`: TRUE 
  
  bare user packages with no constraint must be pinned to installed version to keep deps stable
  ── Error ('test-19smallSnapshot_testthat.R:2:3'): small snapshot install pins each package to the requested version ──
  Error: Please install pak (loadNamespace('pak') failed: there is no package called 'pak')
  Backtrace:
      ▆
   1. └─Require:::setupTest() at test-19smallSnapshot_testthat.R:2:3
   2.   └─Require::Install(c("curl", "httr", "waldo")) at ./helper_0.R:25:3
   3.     └─Require::Require(...)
   4.       ├─base::withCallingHandlers(...)
   5.       └─Require:::pakDepsToPkgDT(...)
  
  [ FAIL 16 | WARN 0 | SKIP 31 | PASS 374 ]
  Error:
  ! Test failures.
  Execution halted
ERROR r-release-macos-x86_64

tests

Running ‘testthat.R’ [7s/14s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > # Point pak's pkgcache at a per-session writable cache BEFORE library(Require)
  > # loads pak. Under R CMD check (CRAN policy), pkgcache aborts if R_USER_CACHE_DIR
  > # is unset; without this every Require::Install() inside the test suite errors
  > # with "Please install pak" because pak's namespace fails to load.
  > if (!nzchar(Sys.getenv("R_USER_CACHE_DIR"))) {
  +   .ucd <- tempfile("RequireUserCache_")
  +   dir.create(.ucd, recursive = TRUE, showWarnings = FALSE)
  +   Sys.setenv(R_USER_CACHE_DIR = .ucd)
  +   rm(.ucd)
  + }
  > 
  > library(Require)
  > library(testthat)
  
  Attaching package: 'testthat'
  
  The following object is masked from 'package:Require':
  
      setup
  
  > test_check("Require")
  Saving _problems/test-00pkgSnapshot_testthat-2.R
  Saving _problems/test-02extract_testthat-3.R
  Saving _problems/test-03helpers_testthat-3.R
  Saving _problems/test-08mod
...[truncated]...
cted`: "data.table@1.18.4"
  
  installed data.table must be pinned to its installed version
  ── Failure ('test-17usePak.R:1485:3'): pinInstalledForPak skips user-version-constrained packages ──
  Expected `grepl("^data.table@", out[2])` to be TRUE.
  Differences:
  `actual`:   FALSE
  `expected`: TRUE 
  
  bare user packages with no constraint must be pinned to installed version to keep deps stable
  ── Error ('test-19smallSnapshot_testthat.R:2:3'): small snapshot install pins each package to the requested version ──
  Error: Please install pak (loadNamespace('pak') failed: there is no package called 'pak')
  Backtrace:
      ▆
   1. └─Require:::setupTest() at test-19smallSnapshot_testthat.R:2:3
   2.   └─Require::Install(c("curl", "httr", "waldo")) at ./helper_0.R:25:3
   3.     └─Require::Require(...)
   4.       ├─base::withCallingHandlers(...)
   5.       └─Require:::pakDepsToPkgDT(...)
  
  [ FAIL 16 | WARN 0 | SKIP 31 | PASS 374 ]
  Error:
  ! Test failures.
  Execution halted

Check History

ERROR 3 OK · 10 NOTE · 0 WARNING · 1 ERROR · 0 FAILURE Mar 10, 2026
NOTE r-devel-linux-x86_64-debian-clang

DESCRIPTION meta-information

Missing dependency on R >= 4.1.0 because package code uses the pipe
  |> or function shorthand \(...) syntax added in R 4.1.0.
  File(s) using such syntax:
    ‘Require2.R’ ‘helpers.R’ ‘pak.R’ ‘pkgDep3.R’
NOTE r-devel-linux-x86_64-debian-gcc

DESCRIPTION meta-information

Missing dependency on R >= 4.1.0 because package code uses the pipe
  |> or function shorthand \(...) syntax added in R 4.1.0.
  File(s) using such syntax:
    ‘Require2.R’ ‘helpers.R’ ‘pak.R’ ‘pkgDep3.R’
NOTE r-devel-linux-x86_64-fedora-clang

DESCRIPTION meta-information

Missing dependency on R >= 4.1.0 because package code uses the pipe
  |> or function shorthand \(...) syntax added in R 4.1.0.
  File(s) using such syntax:
    ‘Require2.R’ ‘helpers.R’ ‘pak.R’ ‘pkgDep3.R’
NOTE r-devel-linux-x86_64-fedora-gcc

DESCRIPTION meta-information

Missing dependency on R >= 4.1.0 because package code uses the pipe
  |> or function shorthand \(...) syntax added in R 4.1.0.
  File(s) using such syntax:
    ‘Require2.R’ ‘helpers.R’ ‘pak.R’ ‘pkgDep3.R’
NOTE r-devel-macos-arm64

DESCRIPTION meta-information

Missing dependency on R >= 4.1.0 because package code uses the pipe
  |> or function shorthand \(...) syntax added in R 4.1.0.
  File(s) using such syntax:
    ‘Require2.R’ ‘helpers.R’ ‘pak.R’ ‘pkgDep3.R’
ERROR r-devel-windows-x86_64

DESCRIPTION meta-information

Missing dependency on R >= 4.1.0 because package code uses the pipe
  |> or function shorthand \(...) syntax added in R 4.1.0.
  File(s) using such syntax:
    'Require2.R' 'helpers.R' 'pak.R' 'pkgDep3.R'
NOTE r-patched-linux-x86_64

DESCRIPTION meta-information

Missing dependency on R >= 4.1.0 because package code uses the pipe
  |> or function shorthand \(...) syntax added in R 4.1.0.
  File(s) using such syntax:
    ‘Require2.R’ ‘helpers.R’ ‘pak.R’ ‘pkgDep3.R’
NOTE r-release-linux-x86_64

DESCRIPTION meta-information

Missing dependency on R >= 4.1.0 because package code uses the pipe
  |> or function shorthand \(...) syntax added in R 4.1.0.
  File(s) using such syntax:
    ‘Require2.R’ ‘helpers.R’ ‘pak.R’ ‘pkgDep3.R’
NOTE r-release-macos-arm64

DESCRIPTION meta-information

Missing dependency on R >= 4.1.0 because package code uses the pipe
  |> or function shorthand \(...) syntax added in R 4.1.0.
  File(s) using such syntax:
    ‘Require2.R’ ‘helpers.R’ ‘pak.R’ ‘pkgDep3.R’
NOTE r-release-macos-x86_64

DESCRIPTION meta-information

Missing dependency on R >= 4.1.0 because package code uses the pipe
  |> or function shorthand \(...) syntax added in R 4.1.0.
  File(s) using such syntax:
    ‘Require2.R’ ‘helpers.R’ ‘pak.R’ ‘pkgDep3.R’
NOTE r-release-windows-x86_64

DESCRIPTION meta-information

Missing dependency on R >= 4.1.0 because package code uses the pipe
  |> or function shorthand \(...) syntax added in R 4.1.0.
  File(s) using such syntax:
    'Require2.R' 'helpers.R' 'pak.R' 'pkgDep3.R'

Reverse Dependencies (1)

imports

Dependency Network

Dependencies Reverse dependencies data.table pak sys SpaDES.core Require

Version History

19 tracked
updated 2.0.0 ← 1.0.1 diff May 15, 2026
new 1.0.1 Mar 10, 2026
updated 1.0.1 ← 1.0.0 diff Aug 17, 2024
updated 1.0.0 ← 0.3.1 diff Jul 26, 2024
updated 0.3.1 ← 0.3.0 diff May 21, 2023
updated 0.3.0 ← 0.2.6 diff Mar 14, 2023
updated 0.2.6 ← 0.2.5 diff Jan 4, 2023
updated 0.2.5 ← 0.1.4 diff Nov 23, 2022
updated 0.1.4 ← 0.1.2 diff Oct 6, 2022
updated 0.1.2 ← 0.0.13 diff Sep 22, 2022
updated 0.0.13 ← 0.0.12 diff May 30, 2021
updated 0.0.12 ← 0.0.10 diff May 25, 2021
updated 0.0.10 ← 0.0.9 diff Dec 1, 2020
updated 0.0.9 ← 0.0.8 diff Nov 29, 2020
updated 0.0.8 ← 0.0.7 diff Sep 9, 2020