Require
Installing and Loading R Packages for Reproducible Workflows
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
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)
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
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
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
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
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’
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’
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’
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’
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’
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'
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’
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’
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’
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’
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'