Skip to content

Start the run_r worker with R's default packages - #213

Merged
TroyHernandez merged 2 commits into
mainfrom
worker-default-packages
Sep 16, 2026
Merged

TroyHernandez merged 2 commits into
mainfrom
worker-default-packages

Conversation

@TroyHernandez

Copy link
Copy Markdown
Contributor

A supervised run_r worker (run_r_mode = "worker") is a bare
callr::r_session, which starts R with only base plus callr's own tools on
the search path. So common helpers from utils/stats/methods (str,
tail, head, setNames, capture.output, ...) are missing, unlike
in-process run_r, which inherits the front end's default packages.

This sets R_DEFAULT_PACKAGES to R's normal default set in the worker's
session options so both run_r_modes see the same base environment. A host
that sets R_DEFAULT_PACKAGES itself (in run_r_worker_options$env) still
wins.

Found while auditing a MazeBench campaign: the model's worker run_r kept
failing with could not find function "str"/"tail"/"setNames"/"capture.output".

  • R/run-r-worker.R: append R_DEFAULT_PACKAGES to the worker options env.
  • Test: default options carry it, a host override wins, and a spawned worker
    has str/tail/setNames on its search path.

🤖 Generated with Claude Code

A supervised worker is a bare callr::r_session with only base plus callr's
tools attached, so utils/stats/methods helpers (str, tail, head, setNames,
capture.output) were missing, unlike in-process run_r. Set
R_DEFAULT_PACKAGES for the worker so both run_r_modes share the same base
environment; a host that sets it in run_r_worker_options$env still wins.
@TroyHernandez
TroyHernandez merged commit 7da0b46 into main Sep 16, 2026
2 checks passed
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.

1 participant