r-lib / remotes

Install R packages from GitHub, GitLab, Bitbucket, git, svn repositories, URLs
https://remotes.r-lib.org/
Other
332 stars 152 forks source link

Possible for dependency installations to "inherit" the value of dependencies argument? #761

Closed richarddmorey closed 1 year ago

richarddmorey commented 1 year ago

I have two packages:

A: https://github.com/richarddmorey/flexTeaching3.interface (Suggests B) B: https://github.com/richarddmorey/flexTeaching3.examples (Suggests, e.g., rsvg)

Package B is in the Suggests for package A, and package B also has all of its dependencies in Suggests (because they are Rmd examples stored in inst/).

When I install package A with

remotes::install_github('richarddmorey/flexTeaching3.interface', dependencies = TRUE)

it installs Package B, as expected:

find.package('flexTeaching3.examples')
# [1] "/Users/saprm3/Downloads/test_remotes/renv/library/R-4.3/aarch64-apple-darwin20/flexTeaching3.examples"

But does not install any of the Suggests of package B, making the package incomplete:

find.package('rsvg')
# Error in find.package("rsvg") : there is no package called ‘rsvg’

I would like to be able to apply the value of the dependency argument (TRUE, in this case, so that Suggests are installed) in turn to the installation of dependencies. Is there a way to do this?

gaborcsardi commented 1 year ago

Suggests typically means development dependencies, i.e. packages like testthat to run the test suite of the package. Occasionally people also list optional packages in Suggests, without which the package is still expected to work.

It is a bad idea to try to install all optional dependencies recursively, because in practice that'll be almost all of CRAN, possibly also all of Bioconductor.

Just the recursive dependencies of sf, a dependency of yours, mean almost 5000 packages:

❯ pkgcache::meta_cache_deps("sf", dependencies = list(direct = pkgcache:::dep_types(), indirect = pkgcache:::dep_types()))
# A data frame: 4,771 × 32
   package     version depends suggests license imports linkingto archs enhances
 * <chr>       <chr>   <chr>   <chr>    <chr>   <chr>   <chr>     <chr> <chr>
 1 ADGofTest   0.3      NA      NA      GPL      NA     NA        NA    NA
 2 AER         1.2-10  "R (>=… "boot, … GPL-2 … "stats… NA        NA    NA
 3 AICcmodavg  2.3-2   "R (>=… "betare… GPL (>… "metho… NA        NA    NA
 4 ATR         0.1-1   "grid,… "trtf, … GPL-2   "stats" NA        NA    NA
 5 AUC         0.3.2    NA      NA      GPL (>…  NA     NA        NA    NA
 6 AlgDesign   1.2.1    NA      NA      GPL (>…  NA     NA        AlgD… NA
 7 Amelia      1.8.1   "R (>=… "tcltk,… GPL (>… "forei… Rcpp (>=… Amel… NA
 8 AmesHousing 0.0.4   "R (>=… "covr"   GPL-2   "dplyr… NA        NA    NA
 9 AsioHeaders 1.22.1…  NA      NA      BSL-1.0  NA     NA        NA    NA
10 BB          2019.1… "R (>=… "setRNG… GPL-3   "stats… NA        NA    NA
# ℹ 4,761 more rows
# ℹ 23 more variables: license_restricts_use <chr>, priority <chr>,
#   license_is_foss <chr>, os_type <chr>, repodir <chr>, rversion <chr>,
#   platform <chr>, needscompilation <chr>, ref <chr>, type <chr>,
#   direct <lgl>, status <chr>, target <chr>, mirror <chr>, sources <list>,
#   filesize <dbl>, sha256 <chr>, sysreqs <chr>, built <chr>, published <dttm>,
#   deps <list>, md5sum <chr>, path <chr>
# ℹ Use `print(n = ...)` to see more rows

But if you really want to do this, in theory pak can do it, like this:

pak::pkg_install(
  "richarddmorey/flexTeaching3.interface", 
  dependencies = list(direct = "all", indirect = "all")
)

but in this particular case it is not going to work in practice, because some suggested dependencies are not on CRAN, e.g. some of them are already archived, some have never been on CRAN.

richarddmorey commented 1 year ago

I see, thanks - so I should install B explicitly with install_github, or move the dependencies to "Depends"?

gaborcsardi commented 1 year ago

Yeah, probably Imports, though, not Depends.