Skip to content

Commit 8c14baa

Browse files
Import %||% from rlang so cd runs on R 4.1-4.3
Base R exports %||% only from 4.4.0, and DESCRIPTION allows R 4.1, so cd_cache_fetch() and cd_stac_catalog() failed on R 4.1-4.3 with "could not find function". The test checks the import table: on R >= 4.4 rlang's %||% is base's, so a function comparison cannot see a missing import. Fixes #130 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GignjoKpZADXywTf6pAMgj
1 parent 9d5f257 commit 8c14baa

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎NAMESPACE‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ export(cd_stac_catalog)
2525
export(cd_summary)
2626
export(cd_trend)
2727
export(cd_variables)
28+
importFrom(rlang,"%||%")
2829
importFrom(rlang,.data)
2930
importFrom(rlang,.env)

‎R/cd-package.R‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#' @keywords internal
2-
#' @importFrom rlang .data .env
2+
#' @importFrom rlang .data .env %||%
33
"_PACKAGE"

‎tests/testthat/test-cd-package.R‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
test_that("%||% comes from rlang, so cd runs on R < 4.4 (#130)", {
2+
# Base R exports %||% only from 4.4.0 and DESCRIPTION allows 4.1, so on a
3+
# newer R a missing import goes unnoticed: base's copy answers instead.
4+
# One list entry per importFrom() line, all named "rlang", so read them all.
5+
imports <- getNamespaceImports("cd")
6+
expect_true("%||%" %in% unlist(imports[names(imports) == "rlang"]))
7+
})

0 commit comments

Comments
 (0)