ropensci-review-tools / goodpractice

Advice on R Package Building
https://docs.ropensci.org/goodpractice/
Other
465 stars 37 forks source link

Calling `gp()` on a loaded package could work better by temporarily unloading it #168

Closed olivroy closed 3 months ago

olivroy commented 5 months ago

It may be possible to use techniques used in pkgdown or usethis to achieve this.

  pkgload::load_all(path, quiet = TRUE)
  withr::defer(pkgload::unload("templatepackage"), envir = env)

Reprex

# in the goodpractice repo
devtools::load_all()
gp() # especially the covr check has issues.

I haven't tested fully, but locally if you have any package loaded with load_all(), it isn't really possible to run gp() and get all results due to some steps failing with Can't install a loaded package..

https://github.com/r-lib/pkgdown/blob/0e1352c92ff4ca8a3ba6e98863e710f14e18a632/R/pkgdown.R#L58-L77

I noticed this while working on #167 but came across this code in local_pkgdown_template_pkg(), so it may be possible to adapt it for goodpractice

mpadge commented 5 months ago

I donj't ever see any errors running gp() on a load_all() package. My guess is that this problem is specific to some particular configuration of OS, dev environment, whatever, and not a general issue? Any more details about how you think the problem can be reproduced?

olivroy commented 5 months ago

Oh, thanks for verifying. Yeah, I am on Windows... Maybe that's a reason why? Paths cannot be easily overwritten there. I will try coming up with something more concrete!

olivroy commented 3 months ago

turns out this was a covr issue https://github.com/r-lib/covr/pull/575. now fixed