R "could not find function X" in CI
R evaluated a call to a function name that is not on the search path. The package that exports it was never attached with library(), or the installed version no longer defines that function.
What this error means
A script fails with "Error in ... : could not find function 'X'", typically because the package was installed but not loaded, or a different version is installed in CI.
Error in mutate(df, y = x + 1) : could not find function "mutate"
Execution haltedCommon causes
The package is installed but not attached
The function exists in a package that was never loaded with library(), so its name is not visible on the search path.
A version mismatch removed or renamed the function
CI resolved a different package version in which the function was renamed, removed, or not yet added.
How to fix it
Attach the package or qualify the call
- Load the package with
library()before calling its functions. - Or call it fully qualified as
pkg::fn(). - Re-run to confirm the function resolves.
library(dplyr)
# or call it without attaching:
dplyr::mutate(df, y = x + 1)Pin the package version that defines it
If the function moved between versions, pin a version that still exports it and record it in the lockfile.
Rscript -e 'remotes::install_version("dplyr", version="1.1.4")'How to prevent it
- Attach every package a script uses, or qualify calls with
pkg::. - Lock package versions so the exported function set is stable.
- Re-run installs after version bumps to catch renamed functions.