rcmdcheck examples failing, but devtools::run_examples(fresh = TRUE) works?

Hi! I'm struggling with R CMD check finding errors in my package examples, but not when I run devtools::run_examples(fresh = TRUE).

The package in question is here: GitHub - ffverse/ffscrapr: R API Client for Fantasy Football League Platforms (the failing branch being feature/env)

and an example of (an automated) check failure: start work on putting GET into an environment object by tanho63 · Pull Request #25 · ffverse/ffscrapr · GitHub

and yet the same example works fine via devtools::run_example(fresh = TRUE) :

I started getting this issue specifically in this feature branch, which involved moving an object into the global environment via the .onLoad() function in zzz.R, and then I'm referencing it via get() in my main package functions, so I'm curious if it's related to not finding the object in the global env.

Would love to hear any thoughts!

Ended up refactoring the global environment object (which in itself was an environment) by putting it into the baseenv() instead, and then referring to that environment instead of just using inherits = TRUE in the succeeding get and assign functions. That seems to have solved the problem! (the changes that solved it are shown in this git diff start work on putting GET into an environment object by tanho63 · Pull Request #25 · dynastyprocess/ffscrapr · GitHub)

Edit (2021-06-08) - put it into emptyenv(), not baseenv()

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.