unable to find an inherited method for function ‘meta<-’ for signature ‘"rule", "character"’
I see this problem, any idea?
R> library(validate)
R> v <- validator(x > 0, y > 0)
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘meta<-’ for signature ‘"rule", "character"’
R> sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] magrittr_2.0.1 datamods_1.1.0 shiny_1.5.0.9006 validate_1.0.1.6 testthat_3.0.2 devtools_2.3.2 usethis_2.0.1
loaded via a namespace (and not attached):
I have seen something like this in tests of validate. It happened after testthat was updated, and in part inspired me to write the tinytest package and remove testthat from my workflow completely. I spent quite some time trying to reproduce it and my suspicion is that there is a collision with one of the dependencies in testthat (crayon, because it also provides a rule object). But it is hard to debug and trace.
Can you show me which packages you load and in what order, before you call library(validate)? Because I see from the sessionInfo() that your example is not completely reproducible (and there is a bunch of masking going on between the packages)
Thanks for pointing into that direction - I'll have a look and investigate!
library(validate)
shows only masking for compare ?
Attaching package: ‘validate’
The following object is masked from ‘package:testthat’:
compare
I attach devtools, testthat & usethis on startup via .Rprofile for convenience.
Here's a cleaner sessionInfo directly after startup:
R> sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] validate_1.0.1 testthat_3.0.2 devtools_2.3.2 usethis_2.0.1
loaded via a namespace (and not attached):
[1] rstudioapi_0.13 magrittr_2.0.1 pkgload_1.2.0 R6_2.5.0
[5] rlang_0.4.10 fastmap_1.0.1 tools_4.0.4 grid_4.0.4
[9] pkgbuild_1.2.0 sessioninfo_1.1.1 cli_2.3.1 withr_2.4.1
[13] ellipsis_0.3.1 remotes_2.2.0 yaml_2.2.1 assertthat_0.2.1
[17] rprojroot_2.0.2 lifecycle_0.2.0 crayon_1.3.4 processx_3.4.5
[21] purrr_0.3.4 callr_3.5.1 settings_0.2.4 fs_1.5.0
[25] ps_1.5.0 memoise_2.0.0 glue_1.4.2 cachem_0.0.0.9000
[29] compiler_4.0.4 desc_1.2.0 prettyunits_1.1.1
Unloaded everything, still the same:
R> sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices datasets utils methods base
loaded via a namespace (and not attached):
[1] rstudioapi_0.13 pkgload_1.2.0 R6_2.5.0 rlang_0.4.10
[5] fastmap_1.0.1 tools_4.0.4 grid_4.0.4 sessioninfo_1.1.1
[9] cli_2.3.1 withr_2.4.1 ellipsis_0.3.1 remotes_2.2.0
[13] yaml_2.2.1 assertthat_0.2.1 rprojroot_2.0.2 lifecycle_0.2.0
[17] processx_3.4.5 callr_3.5.1 settings_0.2.4 fs_1.5.0
[21] ps_1.5.0 memoise_2.0.0 glue_1.4.2 cachem_0.0.0.9000
[25] compiler_4.0.4 prettyunits_1.1.1
Same with a vanilla(!) R:
$> R --vanilla -e "library(validate);sessionInfo();validator(x > 0)"
R version 4.0.4 (2021-02-15) -- "Lost Library Book"
[snip]
> library(validate);sessionInfo();validator(x > 0)
R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] validate_1.0.1
loaded via a namespace (and not attached):
[1] compiler_4.0.4 yaml_2.2.1 grid_4.0.4 settings_0.2.4
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘meta<-’ for signature ‘"rule", "character"’
Calls: validator ... <Anonymous> -> ini_validator -> meta<- -> <Anonymous>
Execution halted
The line causing this seems to be
https://github.com/data-cleaning/validate/blob/b9350b0843f96fcc5b4bfad6d5cc574ae529dacf/pkg/R/validator.R#L97
and this is clearly a "character".
meta<-
should be also there: https://github.com/data-cleaning/validate/blob/8e5e13522408a551fc08cf2e05829d48e3464f27/pkg/R/rule.R#L300
and is exported.
R> `meta<-`
standardGeneric for "meta<-" defined from package "validate"
function (x, name, value)
standardGeneric("meta<-")
<bytecode: 0x558ebb58de90>
<environment: 0x558ebb8a2d38>
Methods may be defined for arguments: x, name, value
Use showMethods("meta<-") for currently available ones.
R> showMethods("meta<-")
Function: meta<- (package validate)
x="expressionset", name="character"
x="rule", name="character"
I am confused...
This is confusing, to me as well. Also because I cannot reproduce your problem. Here's my attempt:
mark@ur:~$ R --vanilla -e "library(validate);sessionInfo();validator(x > 0)"
R version 4.0.4 (2021-02-15) -- "Lost Library Book"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(validate);sessionInfo();validator(x > 0)
R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=nl_NL.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=nl_NL.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=nl_NL.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=nl_NL.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] validate_1.0.1
loaded via a namespace (and not attached):
[1] compiler_4.0.4 yaml_2.2.1 grid_4.0.4 settings_0.2.4
Object of class 'validator' with 1 elements:
V1: x > 0
That's weird, R & packages versions seem to same.
Differences are only
- OS (20.04 vs 18.04)
- locales
- BLAS
all of which I can't believe beeing the root cause. 🤯
Indeed. Maybe there are some options() or environment variables that differ? A fresh reinstall of R&packages is worth a try. OTOH I'd like to find a way to reproduce this because if it is something I can fix, I want to fix it..
I also get this error when trying to load this package through devtools load_all() in the /pkg directory. But not when loading the package through library(validate)
So the solution is obvious there ;-)
I wanted to write some documentation for another function and do a PR. But I guess that's of the table haha