"Error: `map_df()` requires dplyr" when running checks on a package using purrr::map_dfr() internally

A package I'm working on uses purrr::map_dfr() internally in some of its functions. Both purrr and dplyr are included in the Imports in my Description file.

Both examples and tests obviously include these functions using purrr::map_dfr() internally, and when run e.g. with devtools::test() all works fine, all tests are passed. However, when I run devtools::check() I get the following error:

Error: `map_df()` requires dplyr

This is puzzling, as dplyr is imported. Also, I run multiple checks both with Rhub and on Github and none throws the same error.

I'm on the latest Fedora, R4.0.4, all packages are up to date. Any idea on how to troubleshoot this further?

Looking for the error message online I found only references to old issues and debates, which should not be relevant in my case.

Is your package public?

I have no good guess as to what's happening. The function checking the installation is rlang::check_installed().

Hi, thanks a lot for reaching out!

I asked here somehow expecting I was missing something obvious and silly, not sure it's worth troubleshooting in depth.

rhub::check_for_cran() and on checks run on GitHub are mostly happy with it, however, so it must be something on my machine that does no harm (except depriving me of the joy of seeing the three 0/0/0 after checks).

On my machine, I still see that error with purrr, as well as another one, Error: there is no package called 'generics'

Here's the package anyway: GitHub - EDJNet/tidywikidatar: Interact with Wikidata and get tidy data frames in response
I plan to refactor some functions and submit it to cran in the coming weeks.

If there's some input as to what may be causing it, I'm happy to check this out, or I'll try to troubleshoot this further seeing results with other packages. If not, no big deal, I'll ignore those errors and rely on the rest.

Ah interesting that it's only on your machine! What if you try one of R-hub's platforms that's on Fedora too? (see rhub::platforms()).

Also, do you have any particular library setup?

I'm just curious, I'd understand your not exploring further if the problem is only on one machine (too bad it's yours though :wink:).

So... I think I figured this out.

I tried a couple of things, including different rhub platforms and all was fine. Eventually, I re-cloned the package in a new folder and project, activated renv, installed packages. And... everything worked fine, from the project with renv enabled.

So I thought I'd just wipe my R folder with all packages, and install them anew. But no, I had even more errors, with other packages, besides purrr and dplyr, such as httr.

I then installed manually all these packages with install.package(), and... now all is fine.

In brief, the issue must be that packages that are installed via the OS package manager are not visible to devtools::check(). To make them available to check, I apparently need to install them again from inside R, even if otherwise everything works just fine.

(Fedora has in its repo many R packages, that I installed with something like sudo dnf install R-httr... these are useful, as they solve a number of issues with dependencies).

1 Like

Wow, this is weird, good to have some sort of explanation!

1 Like

Thanks! Yes... if I get some time I may try this on a fresh install that relies on system packages and see if this is something worth reporting.

1 Like

This topic was automatically closed after 45 days. New replies are no longer allowed.


If you have a query related to it or one of the replies, start a new topic and refer back with a link.