r-lib / pkgdepends

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

Solver fails with Config/Needs/... indirect dependency configuration #351

Open pawelru opened 10 months ago

pawelru commented 10 months ago
library(pkgdepends)

deps_1 <- c("config/needs/foo", pkg_dep_types_hard())
deps_2 <- list(
    direct = c("config/needs/foo", pkg_dep_types_hard()),
    indirect = pkg_dep_types()
)
deps_3 <- list(
    direct = c("config/needs/foo", pkg_dep_types_hard()),
    indirect = c("config/needs/bar", pkg_dep_types()) # <- here!
)

foo <- function(deps) {
    ip <- new_pkg_installation_proposal("r-lib/rlang", config = list(dependencies = deps))
    ip$solve()
    ip$get_solution()
}

foo(deps_1) # OK
#> ℹ Loading metadata database
#> ✔ Loading metadata database ... done
#> 
#> <pkg_solution>
#> + result: OK
#> + refs:
#>   - r-lib/rlang
#> + constraints (2):
#>   - select rlang exactly once
#>   - `r-lib/rlang` is not satisfied by `installed::/Users/ruckip/Library/R/arm64/4.3/library/rlang`
#> + solution:
#>   - r-lib/rlang
foo(deps_2) # OK
#> <pkg_solution>
#> + result: OK
#> + refs:
#>   - r-lib/rlang
#> + constraints (27915):
#>   - `rnaturalearthhires` resolution failed
#>   - `starsdata` resolution failed
#>   - `cmdstanr` resolution failed
#>   - `glmmADMB` resolution failed
#>   - `ffbase` resolution failed
#>   - `spDataLarge` resolution failed
#>   - `mnlogit` resolution failed
#>   - `Zelig` resolution failed
#>   - `ergm.userterms` resolution failed
#>   - `corpus.useR.2008.abstracts` resolution failed
#>   ...
#> + solution:
#>   - r-lib/rlang
foo(deps_3) # FAIL
#> Error in value$ref %in% private$state$ref && !value$direct: 'length = 18' in coercion to 'logical(1)'

Created on 2024-01-04 with reprex v2.0.2

gaborcsardi commented 10 months ago

config/needs/... is not allowed in the indirect dependencies, because we don't have that field in CRAN-like repos. config/needs/... is mainly for local packages, but it happens to work for git/github/url packages as well.

pawelru commented 10 months ago

Thanks for giving some explanation. Even though custom fields are not supported for CRAN-like repos, my use case is GitHub so it would be great to have it working. If it's truly forbidden then I would expect that it will be caught earlier (possibly pkgdepends::as_pkg_dependencies()) as opposed to length coercion error.