Skip to content

Call .onLoad during package loading#10

Merged
felix-andreas-finccam merged 2 commits into
mainfrom
copilot/make-loadfast-call-onload
Apr 14, 2026
Merged

Call .onLoad during package loading#10
felix-andreas-finccam merged 2 commits into
mainfrom
copilot/make-loadfast-call-onload

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 10, 2026

loadfast was not calling .onLoad hooks (typically defined in zzz.R), unlike devtools::load_all() and normal R package loading. Packages relying on .onLoad for initialization (options, registrations, connections, etc.) would silently skip that setup.

Changes

  • .loadfast.run_onload() helper — calls ns_env$.onLoad(dirname(abs_path), pkg_name) if defined, matching standard R argument convention; errors are downgraded to warnings
  • Full load: .onLoad fires after exports are set and testthat is attached, but before attach() — matching standard R ordering (.onLoad before .onAttach)
  • Incremental reload: .onLoad fires after changed files are re-sourced and pkg env is synced; skipped on the no-change short-circuit
  • Tests (Stage 4l): verifies correct libname/pkgname arguments, suppression on no-change reload, and re-invocation on incremental reload

Example

# R/zzz.R
.onLoad <- function(libname, pkgname) {
  options(mypkg.timeout = 30L)
}

Previously load_fast() would ignore this; now it is called on every load that sources files.

Copilot AI linked an issue Apr 10, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Update loadfast to call .onLoad during package loading Call .onLoad during package loading Apr 10, 2026
Copilot AI requested a review from ak-finccam April 10, 2026 16:13
@ak-finccam ak-finccam marked this pull request as ready for review April 10, 2026 17:42
@ak-finccam
Copy link
Copy Markdown
Contributor

@felix-andreas-finccam Ich würde das hier dann mergen, richtig?

@felix-andreas-finccam felix-andreas-finccam merged commit b22ae22 into main Apr 14, 2026
2 checks passed
@felix-andreas-finccam
Copy link
Copy Markdown
Contributor

hab's gemergt

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.

Call .onLoad during package loading

3 participants