Skip to content

Fix R-devel CI: pin roxygen2 7.2.3 on all platforms, add layered tryCatch fallbacks#142

Merged
GegznaV merged 1 commit intoimpove-gha-workflowsfrom
copilot/fix-r-cmd-check-workflow-again
Mar 24, 2026
Merged

Fix R-devel CI: pin roxygen2 7.2.3 on all platforms, add layered tryCatch fallbacks#142
GegznaV merged 1 commit intoimpove-gha-workflowsfrom
copilot/fix-r-cmd-check-workflow-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 24, 2026

roxygen2 ≥ 7.3.0 has a parser_setMethod bug — it calls methods::getMethod() with no error handling, which crashes in clean Rscript sessions when S4 method tables for primitives ([[, [, $) are unpopulated. R-devel was exempt from the 7.2.3 pin, so it used 7.3.x and failed every run with no method found for function '[[' and signature hyperSpec.

A secondary issue: the tryCatch fallback called git checkout HEAD -- NAMESPACE man/, but both are gitignored and untracked — always failing with pathspec did not match any file(s) known to git, leaving no NAMESPACE for R CMD check.

Changes

  • R-CMD-check.yaml
    • Remove if: matrix.config.r != 'devel' from "Install roxygen2 7.2.3" — pins 7.2.3 on all platforms including R-devel
    • Replace the single-step git restore in the tryCatch error handler with two ordered fallbacks:
      1. git restore — succeeds if NAMESPACE/man/ are ever pre-committed (Bioconductor/Matrix pattern)
      2. Source-compile roxygen2 7.2.3 against current R headers — handles future C-ABI breaks (e.g. SET_GROWABLE_BIT symbol removal in R 4.6.0-pre) where the RSPM binary fails but a freshly compiled .so succeeds
    • Update comments to reflect actual failure mode (parser_setMethod, not ABI break)
ok <- tryCatch({
  devtools::document()
  TRUE
}, error = function(e) {
  message("devtools::document() failed: ", conditionMessage(e))

  # Fallback 1: restore from git (works when docs are pre-committed)
  ret <- system2("git", c("checkout", "HEAD", "--", "NAMESPACE", "man/"),
                 stdout = TRUE, stderr = TRUE)
  if (file.exists("NAMESPACE")) { message("NAMESPACE restored from git."); return(FALSE) }

  # Fallback 2: compile from source against current R headers
  tryCatch({
    remotes::install_version("roxygen2", "7.2.3", type = "source", quiet = TRUE)
    devtools::document()
    TRUE
  }, error = function(e2) { ...; FALSE })
})

@GegznaV GegznaV marked this pull request as ready for review March 24, 2026 16:44
@GegznaV GegznaV merged commit 8da9085 into impove-gha-workflows Mar 24, 2026
@GegznaV GegznaV deleted the copilot/fix-r-cmd-check-workflow-again branch March 24, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants