F. Privé
F. Privé

Reputation: 11738

Could not find function from same package when using foreach (Windows devel)

Having a function using foreach for parallelization that is using another function in the same package used to be fine. But apparently, it is not anymore for R-devel on Windows??

I'm starting to see this problem is some of my packages so I decided to make a small reproducible example.

You can find a small package to reproduce the problem and the functions there: https://github.com/privefl/minipkg/blob/master/R/test-parallel.R.

You can see the check that fails there: https://github.com/privefl/minipkg/commit/973b2048d43a2c75fcee088f8182776f9cd1f95d/checks?check_suite_id=343796248#step:9:151.

Any idea where it comes from? Is it expected? What to change to make it work again?


Edit: I've added more builds (see https://github.com/privefl/minipkg/runs/339575258);

Upvotes: 2

Views: 443

Answers (1)

Jim
Jim

Reputation: 4767

This error occurs because the foreach code needs to load the package in the child process, but the package is not installed before running the checks on GitHub Actions.

You can see the same result if you try to run R CMD check locally on a Windows machine without first installing the package into your library.

I believe it works on non-Windows systems without installing because the way that R CMD check handles the environment variables controlling the package libraries during R CMD check differs slightly on Windows than elsewhere.

Upvotes: 4

Related Questions