Skip to content

Call utils and stats functions with their namespace - #7

Merged
dfalbel merged 1 commit into
mlverse:mainfrom
cornball-ai:fix/import-utils-stats
Oct 21, 2026
Merged

dfalbel merged 1 commit into
mlverse:mainfrom
cornball-ai:fix/import-utils-stats

Conversation

@TroyHernandez

Copy link
Copy Markdown
Contributor

Fixes #5. Should also fix mlverse/torch#1463.

Related: mlverse/torch#1478 makes torch warn and keep loading when lib_path() errors, instead of reporting that torch failed to start. That guards against the symptom, and this PR fixes the cause.

lib_path(), cuda_path() and .read_components() call packageName(), read.delim() and setNames() without importing utils or stats. When no default packages are attached, every exported path function errors with "could not find function packageName". R CMD INSTALL and R CMD check run R that way. torch calls lib_path() at startup, so with cuda12.8 installed it can't preload the CUDA libraries and fails to start, and any package that loads torch fails R CMD check.

The change qualifies the calls with utils:: and stats::, adds Imports: stats, utils to the DESCRIPTION template, and runs sync.sh to update all four cuda* packages.

Checked with cuda12.8 installed with CUDA_COMPONENTS=runtime:

  • With R_DEFAULT_PACKAGES=NULL, lib_path(), cuda_path(), include_path() and all_lib_paths() all error on main and return the expected paths with this change.
  • With R_DEFAULT_PACKAGES=NULL, loadNamespace("torch") fails on main with "could not find function packageName". With this change torch starts and maps libcudart.so.12 from the cuda12.8 lib directory.
  • R CMD check no longer gives the "no visible global function definition" NOTE for these calls. The missing-documentation WARNING is unchanged, since the packages ship no man pages.

I left PKG_VERSION alone. Installs that already have 1.0.9 will need a version bump to pick this up through update.packages().

`lib_path()`, `cuda_path()` and `.read_components()` called
`packageName()`, `read.delim()` and `setNames()` unqualified, without
importing utils or stats. With no default packages attached, as in
`R_DEFAULT_PACKAGES=NULL` and the child processes of R CMD INSTALL and
R CMD check, every exported path function errored with "could not find
function packageName". A package that loads one of these at load time,
such as torch, then fails to start under R CMD check.

The calls now use `utils::` and `stats::`, both packages are declared in
Imports, and sync.sh has propagated the change to every cuda* package.

Fixes mlverse#5.
@dfalbel
dfalbel merged commit e37ec36 into mlverse:main Oct 21, 2026
4 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.

lib_path(), cuda_path() and .read_components() call packageName() without importing utils Problems loading lantern.so when running R CMD check.

2 participants