r-lib / pkgdepends

R Package Dependency Resolution
https://r-lib.github.io/pkgdepends/
Other
102 stars 30 forks source link

Warning in cond$parent: partial match of 'parent' to 'parents' #365

Open pawelru opened 6 months ago

pawelru commented 6 months ago

Please find below a reprex. I was having a tough times debugging where it is and actually which repo it relates to (here or rlang or processx or something else?). Please feel free to transfer it if needed. From the tracer debug prints - some objects have both parent and parents (hence only the first one is used when calling x$parent) but there are objects that has only parents (which throw a warning on partial match). I guess we can't just change cond$parent to cond$parents as for the first group a different element will be used.

options(list(
  warnPartialMatchDollar = TRUE,
  warnPartialMatchArgs = TRUE,
  warnPartialMatchAttr = TRUE
))

x <- pkgdepends::new_pkg_deps("r-lib/pkgdepends@thisdoesnotexists")
x$solve()
#> Warning in cond$parent: partial match of 'parent' to 'parents'
#> Warning in cond$parent: partial match of 'parent' to 'parents'
#> Warning in cond$parent: partial match of 'parent' to 'parents'
#> Warning in cond$parent: partial match of 'parent' to 'parents'
#> Warning in cond$parent: partial match of 'parent' to 'parents'
#> Warning in cond$parent: partial match of 'parent' to 'parents'
#> Warning in cond$parent: partial match of 'parent' to 'parents'
#> Warning in cond$parent: partial match of 'parent' to 'parents'

catnl <- function(x) {cat(" "); cat(x); cat("\n")}
trace(conditionMessage, tracer = quote({catnl(class(c)); catnl(names(c)); catnl("")}))
#> Tracing function "conditionMessage" in package "base"
#> [1] "conditionMessage"

x$solve()
#> Tracing conditionMessage(e) on entry 
#>  async_rejected rlib_error_3_0 rlib_error error condition
#>  message call srcref id procsrcref parent aframe calls parents
#>  
#> Tracing conditionMessage(cond) on entry 
#>  async_rejected rlib_error error condition
#>  message call srcref id procsrcref parent aframe calls parents
#>  
#> Tracing conditionMessage(cond$parent) on entry 
#>  async_rejected github_error rlib_error_3_0 rlib_error error condition
#>  message srcref procsrcref aframe calls parents id call
#>  
#> Tracing conditionMessage(cond) on entry 
#>  async_rejected github_error rlib_error error condition
#>  message srcref procsrcref aframe calls parents id call
#> 
#> Warning in cond$parent: partial match of 'parent' to 'parents'

Created on 2024-05-17 with reprex v2.1.0

Why tracing conditionMessage? The longer story is that this fails my strict (i.e. with partial match options) tests and I got the following stack trace:

Warning (...)
partial match of 'parent' to 'parents'
Backtrace:
     ▆
  1. └─(...)
  2.   └─x$solve()
  3.     └─private$plan$solve(policy = private$policy)
  4.       └─pkgdepends:::pkgplan_solve(self, private, match.arg(policy))
  5.         └─pkgdepends:::describe_solution_error(pkgs, res)
  6.           ├─base::conditionMessage(e)
  7.           └─conditionMessage.rlib_error_3_0(e)
  8.             ├─base::paste(cnd_message_(cond, full = FALSE), collapse = "\n")
  9.             └─cnd_message_(cond, full = FALSE)
 10.               └─cnd_message_cli(cond, full)
 11.                 ├─base::conditionMessage(cond$parent)
 12.                 └─conditionMessage.rlib_error_3_0(cond$parent)
 13.                   ├─base::paste(cnd_message_(cond, full = FALSE), collapse = "\n")
 14.                   └─cnd_message_(cond, full = FALSE)
 15.                     └─cnd_message_cli(cond, full)