-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in NextMethod after load_all #1636
Comments
I can't reproduce this. Could you try with dev pkgload please? |
Same issue with the dev version. Here is a more reproducible environment: Set up a container and start R: $ podman run --rm -it rocker/r-rspm:20.04 bash
$ apt-get update
$ apt-get install -y git libudunits2-dev
$ git clone https://github.com/r-quantities/units.git && cd units
$ R Then I get: > install.packages(c("Rcpp", "remotes", "pkgbuild"))
> remotes::install_github("r-lib/pkgload")
> remotes::install_local(".")
> iris.u <- iris
> iris.u[1:4] <- lapply(iris.u[1:4], function(x) units::set_units(x, cm))
> plot(Sepal.Length ~ Sepal.Width, iris.u) # plot with units, all ok
> pkgload::load_all()
> plot(Sepal.Length ~ Sepal.Width, iris.u)
Error in NextMethod("plot", xlab = xlab, ylab = ylab) :
no method to invoke |
(Of course, you can use docker instead of podman) |
Actually I can now reproduce locally. This is because of the way
You can reproduce without pkgload in this way: iris.u <- iris
iris.u[1:4] <- lapply(iris.u[1:4], function(x) units::set_units(x, cm))
# Assign the method on the search path
plot.units <- units:::plot.units
plot(Sepal.Length ~ Sepal.Width, iris.u) And you can fix the error with pkgload like this: pkgload::load_all(export_all = FALSE) |
This issue happens when clicking "check" in RStudio, which calls
|
I'm not an RStudio user but I believe the Check button runs oh hmm another path that might explain I can't compile your package under RStudio right now (trouble installing libudunits for x86 and RStudio doesn't run with arm64 R yet it seems). But both |
This is the "base mode" for test that @lionel- is thinking of: r-lib/devtools#2361 |
Yes, I meant "test", not "check".
No, I can always reproduce the issue in a fresh R session outside RStudio (as the container workflow above demonstrates). The main problem of this issue is that I can't add formula-based plots to the package tests, because then those tests fail under But maybe this is not the place for this? Or maybe |
As discussed above I can reproduce your workflow. However it doesn't use
This would require changes in testthat to an already complex evaluation machinery. So before we think about this I would like to understand precisely how the problem manifests to make sure we aren't missing anything. Could you please provide a reprex with |
Sure, that's the easiest thing: $ podman run --rm -it rocker/r-rspm:20.04 bash
$ apt-get update
$ apt-get install -y git libudunits2-dev
$ git clone https://github.com/r-quantities/units.git && cd units
$ Rscript -e 'install.packages(c("Rcpp", "devtools"))'
$ R then > devtools::test()
> iris[1:4] <- lapply(iris[1:4], function(x) units::set_units(x, cm))
> plot(Sepal.Length ~ Sepal.Width, iris)
Error in NextMethod("plot", xlab = xlab, ylab = ylab) :
no method to invoke So, to be clear, |
Thank you, I can reproduce by adding a new vdiffr test for the formula plot. Actually, in this code path ( Line 223 in 2f48ca6
export_all = TRUE to load_all() . We evaluate in the namespace env which contains all the internal functions anyway. The export_all only concerns the package env, the one attached to the search path, and which we don't use much in tests.
The only downside is that after running I think it would make sense to pass |
@lionel- the reason we don't use |
And load helpers to the search path by default to match previous behaviour. Closes #1636
@hadley I did not want to change the default for the reason that you mention. However after examining the issue I thought it makes sense to allow |
And load helpers to the search path by default to match previous behaviour. Closes #1636
Not sure what's going on here, and I have been unable to produce a MVE. This only happened to me with the
units
package. This is a (not minimal) reproducible example:Somehow
load_all
messes up S3 dispatch. Given that this is called bydevtools::test
in RStudio, I'm basically unable to test formula-based plots there.The text was updated successfully, but these errors were encountered: