Dependencies
How to list all dependencies of a CRAN/Bioconductor package?
library(pkgdepends)
prop <- new_pkg_deps("ggplot2")
prop$solve()
prop$get_solution()$data
#> ✔ Loading metadata database ... done #> # A data frame: 28 × 38 #> ref type direct directpkg status package version license needscompilation #> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr> <lgl> #> 1 cli stan… FALSE FALSE OK cli 3.6.3 MIT + … TRUE #> 2 color… stan… FALSE FALSE OK colors… 2.1-1 BSD_3_… TRUE #> 3 fansi stan… FALSE FALSE OK fansi 1.0.6 GPL-2 … TRUE #> 4 farver stan… FALSE FALSE OK farver 2.1.2 MIT + … TRUE #> 5 ggplo… stan… TRUE TRUE OK ggplot2 3.5.1 MIT + … FALSE #> 6 glue stan… FALSE FALSE OK glue 1.7.0 MIT + … TRUE #> 7 gtable stan… FALSE FALSE OK gtable 0.3.5 MIT + … FALSE #> 8 isoba… stan… FALSE FALSE OK isoband 0.2.7 MIT + … TRUE #> 9 label… stan… FALSE FALSE OK labeli… 0.4.3 MIT + … FALSE #> 10 lifec… stan… FALSE FALSE OK lifecy… 1.0.4 MIT + … FALSE #> # ℹ 18 more rows #> # ℹ 29 more variables: priority <chr>, md5sum <chr>, sha256 <chr>, #> # filesize <int>, built <chr>, platform <chr>, rversion <chr>, #> # repotype <chr>, repodir <chr>, target <chr>, deps <list>, mirror <chr>, #> # sources <list>, remote <list>, error <list>, metadata <list>, extra <list>, #> # dep_types <list>, params <list>, sysreqs <chr>, os_type <chr>, #> # cache_status <chr>, sysreqs_packages <list>, sysreqs_pre_install <chr>, … #> # ℹ Use `print(n = ...)` to see more rows
You can also draw a dependency tree:
prop$draw()
#> ggplot2 3.5.1 [new][bld][dl] (3.56 MB) #> ├─cli 3.6.3 [new][bld][cmp][dl] (569.77 kB) #> ├─glue 1.7.0 [new][bld][cmp] #> ├─gtable 0.3.5 [new][bld][dl] (130.10 kB) #> │ ├─cli #> │ ├─glue #> │ ├─lifecycle 1.0.4 [new][bld] #> │ │ ├─cli #> │ │ ├─glue #> │ │ └─rlang 1.1.4 [new][bld][cmp][dl] (763.76 kB) #> │ └─rlang #> ├─isoband 0.2.7 [new][bld][cmp][dl] (1.59 MB) #> ├─lifecycle #> ├─MASS 7.3-60.2 < 7.3-61 [old] #> ├─mgcv 1.9-1 #> │ ├─nlme 3.1-164 < 3.1-166 [old] #> │ │ └─lattice 0.22-6 #> │ └─Matrix 1.7-0 #> │ └─lattice #> ├─rlang #> ├─scales 1.3.0 [new][bld][cmp][dl] (302.54 kB) #> │ ├─cli #> │ ├─farver 2.1.2 [new][bld][cmp][dl] (1.27 MB) #> │ ├─glue #> │ ├─labeling 0.4.3 [new][bld][dl] (10.17 kB) #> │ ├─lifecycle #> │ ├─munsell 0.5.1 [new][bld][dl] (182.31 kB) #> │ │ └─colorspace 2.1-1 [new][bld][cmp][dl] (2.12 MB) #> │ ├─R6 2.5.1 [new][bld] #> │ ├─RColorBrewer 1.1-3 [new][bld][dl] (11.64 kB) #> │ ├─rlang #> │ └─viridisLite 0.4.2 [new][bld][dl] (1.27 MB) #> ├─tibble 3.2.1 [new][bld][cmp][dl] (565.98 kB) #> │ ├─fansi 1.0.6 [new][bld][cmp][dl] (482.48 kB) #> │ ├─lifecycle #> │ ├─magrittr 2.0.3 [new][bld][cmp][dl] (267.07 kB) #> │ ├─pillar 1.9.0 [new][bld][dl] (444.53 kB) #> │ │ ├─cli #> │ │ ├─fansi #> │ │ ├─glue #> │ │ ├─lifecycle #> │ │ ├─rlang #> │ │ ├─utf8 1.2.4 [new][bld][cmp][dl] (241.08 kB) #> │ │ └─vctrs 0.6.5 [new][bld][cmp][dl] (969.07 kB) #> │ │ ├─cli #> │ │ ├─glue #> │ │ ├─lifecycle #> │ │ └─rlang #> │ ├─pkgconfig 2.0.3 [new][bld][dl] (6.08 kB) #> │ ├─rlang #> │ └─vctrs #> ├─vctrs #> └─withr 3.0.1 [new][bld][dl] (107.68 kB) #> #> Key: [new] new | [old] outdated | [dl] download | [bld] build | [cmp] compile
How to list all dependencies of a GitHub package?
library(pkgdepends)
prop <- new_pkg_deps("tidyverse/ggplot2")
prop$solve()
prop$get_solution()$data
#> # A data frame: 18 × 38 #> ref type direct directpkg status package version license needscompilation #> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr> <lgl> #> 1 tidyv… gith… TRUE TRUE OK ggplot2 3.5.1.… MIT + … TRUE #> 2 cli stan… FALSE FALSE OK cli 3.6.3 MIT + … TRUE #> 3 color… stan… FALSE FALSE OK colors… 2.1-1 BSD_3_… TRUE #> 4 farver stan… FALSE FALSE OK farver 2.1.2 MIT + … TRUE #> 5 glue stan… FALSE FALSE OK glue 1.7.0 MIT + … TRUE #> 6 gtable stan… FALSE FALSE OK gtable 0.3.5 MIT + … FALSE #> 7 isoba… stan… FALSE FALSE OK isoband 0.2.7 MIT + … TRUE #> 8 label… stan… FALSE FALSE OK labeli… 0.4.3 MIT + … FALSE #> 9 lifec… stan… FALSE FALSE OK lifecy… 1.0.4 MIT + … FALSE #> 10 munse… stan… FALSE FALSE OK munsell 0.5.1 MIT + … FALSE #> 11 R6 stan… FALSE FALSE OK R6 2.5.1 MIT + … FALSE #> 12 RColo… stan… FALSE FALSE OK RColor… 1.1-3 Apache… FALSE #> 13 rlang stan… FALSE FALSE OK rlang 1.1.4 MIT + … TRUE #> 14 scales stan… FALSE FALSE OK scales 1.3.0 MIT + … TRUE #> 15 vctrs stan… FALSE FALSE OK vctrs 0.6.5 MIT + … TRUE #> 16 virid… stan… FALSE FALSE OK viridi… 0.4.2 MIT + … FALSE #> 17 withr stan… FALSE FALSE OK withr 3.0.1 MIT + … FALSE #> 18 insta… inst… FALSE FALSE OK MASS 7.3-60… GPL-2 … TRUE #> # ℹ 29 more variables: priority <chr>, md5sum <chr>, sha256 <chr>, #> # filesize <int>, built <chr>, platform <chr>, rversion <chr>, #> # repotype <chr>, repodir <chr>, target <chr>, deps <list>, mirror <chr>, #> # sources <list>, remote <list>, error <list>, metadata <list>, extra <list>, #> # dep_types <list>, params <list>, sysreqs <chr>, os_type <chr>, #> # cache_status <chr>, sysreqs_packages <list>, sysreqs_pre_install <chr>, #> # sysreqs_post_install <chr>, sysreqs_install <chr>, lib_status <chr>, …
How to list all dependencies of a local package?
library(pkgdepends)
prop <- new_pkg_deps("local::.")
prop$solve()
prop$get_solution()$data
#> # A data frame: 14 × 38 #> ref type direct directpkg status package version license needscompilation #> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr> <lgl> #> 1 local… local TRUE TRUE OK pkgdep… 0.8.0 MIT + … NA #> 2 callr stan… FALSE FALSE OK callr 3.7.6 MIT + … FALSE #> 3 cli stan… FALSE FALSE OK cli 3.6.3 MIT + … TRUE #> 4 curl stan… FALSE FALSE OK curl 5.2.2 MIT + … TRUE #> 5 desc stan… FALSE FALSE OK desc 1.4.3 MIT + … FALSE #> 6 filel… stan… FALSE FALSE OK filelo… 1.0.3 MIT + … TRUE #> 7 jsonl… stan… FALSE FALSE OK jsonli… 1.8.8 MIT + … TRUE #> 8 lpSol… stan… FALSE FALSE OK lpSolve 5.6.21 LGPL-2 TRUE #> 9 pkgbu… stan… FALSE FALSE OK pkgbui… 1.4.4 MIT + … FALSE #> 10 pkgca… stan… FALSE FALSE OK pkgcac… 2.2.3 MIT + … TRUE #> 11 proce… stan… FALSE FALSE OK proces… 3.8.4 MIT + … TRUE #> 12 ps stan… FALSE FALSE OK ps 1.8.0 MIT + … TRUE #> 13 R6 stan… FALSE FALSE OK R6 2.5.1 MIT + … FALSE #> 14 zip stan… FALSE FALSE OK zip 2.3.1 MIT + … TRUE #> # ℹ 29 more variables: priority <chr>, md5sum <chr>, sha256 <chr>, #> # filesize <int>, built <chr>, platform <chr>, rversion <chr>, #> # repotype <chr>, repodir <chr>, target <chr>, deps <list>, mirror <chr>, #> # sources <list>, remote <list>, error <list>, metadata <list>, extra <list>, #> # dep_types <list>, params <list>, sysreqs <chr>, os_type <chr>, #> # cache_status <chr>, sysreqs_packages <list>, sysreqs_pre_install <chr>, #> # sysreqs_post_install <chr>, sysreqs_install <chr>, lib_status <chr>, …
Downloads
How to download a package and all of its dependencies?
library(pkgdepends)
target_dir <- tempfile()
dir.create(target_dir)
prop <- new_pkg_download_proposal("ggplot2", config = list(cache_dir = target_dir))
prop$resolve()
prop$download()
prop$get_downloads()
dir(target_dir)
#> ℹ Getting 30 pkgs (26.31 MB), 3 (276.50 kB) cached #> ✔ Cached copy of cli 3.6.3 (source) is the latest build #> ✔ Got pkgconfig 2.0.3 (source) (6.08 kB) #> ✔ Cached copy of rlang 1.1.4 (source) is the latest build #> ✔ Got fansi 1.0.6 (source) (482.48 kB) #> ✔ Got pillar 1.9.0 (source) (444.53 kB) #> ✔ Got gtable 0.3.5 (source) (130.23 kB) #> ✔ Got vctrs 0.6.5 (source) (969.07 kB) #> ✔ Got munsell 0.5.1 (source) (182.31 kB) #> ✔ Got isoband 0.2.7 (source) (1.59 MB) #> ✔ Cached copy of withr 3.0.1 (source) is the latest build #> ✔ Got mgcv 1.9-1 (source) (1.08 MB) #> ✔ Got lattice 0.22-6 (source) (598.58 kB) #> ✔ Got RColorBrewer 1.1-3 (source) (11.64 kB) #> ✔ Got colorspace 2.1-1 (source) (2.14 MB) #> ✔ Got scales 1.3.0 (source) (302.54 kB) #> ✔ Got lattice 0.22-6 (source) (598.58 kB) #> ✔ Got magrittr 2.0.3 (source) (267.07 kB) #> ✔ Got MASS 7.3-61 (source) (509.90 kB) #> ✔ Got farver 2.1.2 (source) (1.28 MB) #> ✔ Got Matrix 1.7-0 (source) (2.47 MB) #> ✔ Got tibble 3.2.1 (source) (565.98 kB) #> ✔ Got viridisLite 0.4.2 (source) (1.27 MB) #> ✔ Got labeling 0.4.3 (source) (10.17 kB) #> ✔ Got MASS 7.3-61 (source) (509.90 kB) #> ✔ Got nlme 3.1-166 (source) (847.67 kB) #> ✔ Got utf8 1.2.4 (source) (241.08 kB) #> ✔ Got Matrix 1.7-0 (source) (2.47 MB) #> ✔ Got nlme 3.1-166 (source) (847.67 kB) #> ✔ Got mgcv 1.9-1 (source) (1.08 MB) #> ✔ Got ggplot2 3.5.1 (source) (3.60 MB) #> # A data frame: 33 × 40 #> ref type direct directpkg status package version license needscompilation #> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr> <lgl> #> 1 cli stan… FALSE FALSE OK cli 3.6.3 MIT + … TRUE #> 2 color… stan… FALSE FALSE OK colors… 2.1-1 BSD_3_… TRUE #> 3 fansi stan… FALSE FALSE OK fansi 1.0.6 GPL-2 … TRUE #> 4 farver stan… FALSE FALSE OK farver 2.1.2 MIT + … TRUE #> 5 ggplo… stan… TRUE TRUE OK ggplot2 3.5.1 MIT + … FALSE #> 6 glue stan… FALSE FALSE OK glue 1.7.0 MIT + … TRUE #> 7 gtable stan… FALSE FALSE OK gtable 0.3.5 MIT + … FALSE #> 8 isoba… stan… FALSE FALSE OK isoband 0.2.7 MIT + … TRUE #> 9 label… stan… FALSE FALSE OK labeli… 0.4.3 MIT + … FALSE #> 10 latti… stan… FALSE FALSE OK lattice 0.22-6 GPL (>… TRUE #> # ℹ 23 more rows #> # ℹ 31 more variables: priority <chr>, md5sum <chr>, sha256 <chr>, #> # filesize <int>, built <chr>, platform <chr>, rversion <chr>, #> # repotype <chr>, repodir <chr>, target <chr>, deps <list>, mirror <chr>, #> # sources <list>, remote <list>, error <list>, metadata <list>, extra <list>, #> # dep_types <list>, params <list>, sysreqs <chr>, os_type <chr>, #> # cache_status <chr>, sysreqs_packages <list>, sysreqs_pre_install <chr>, … #> # ℹ Use `print(n = ...)` to see more rows #> [1] "src"
Installation
How to install a package into a new library?
library(pkgdepends)
dir.create(new_lib <- tempfile())
prop <- new_pkg_installation_proposal("pkgconfig", config = list(library = new_lib))
prop$solve()
prop$download()
prop$install()
lib_status(new_lib)
#> ℹ No downloads are needed, 1 pkg (6.08 kB) is cached #> ℹ Building pkgconfig 2.0.3 #> ✔ Built pkgconfig 2.0.3 (845ms) #> ✔ Installed pkgconfig 2.0.3 (1s) #> ✔ Summary: 1 new in 1.9s #> # A data frame: 1 × 31 #> library package title version license imports suggests needscompilation #> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <lgl> #> 1 /tmp/RtmpVe0z… pkgcon… Priv… 2.0.3 MIT + … utils covr, t… FALSE #> # ℹ 23 more variables: repository <chr>, built <chr>, remotetype <chr>, #> # remotepkgref <chr>, remoteref <chr>, remoterepos <chr>, #> # remotepkgplatform <chr>, remotesha <chr>, depends <chr>, linkingto <chr>, #> # enhances <chr>, md5sum <chr>, platform <chr>, priority <chr>, #> # biocviews <chr>, sysreqs <chr>, ref <chr>, type <chr>, status <chr>, #> # rversion <chr>, sources <list>, repotype <chr>, deps <list>
How to update a package?
Install an older version first.
library(pkgdepends)
dir.create(new_lib <- tempfile())
config <- list(library = new_lib)
prop <- new_pkg_installation_proposal("cran/pkgconfig@2.0.2", config = config)
prop$solve()
prop$download()
prop$install()
lib_status(new_lib)
#> ℹ No downloads are needed, 1 pkg is cached #> ✔ Got pkgconfig 2.0.2 (source) (13.22 kB) #> ℹ Packaging pkgconfig 2.0.2 #> ✔ Packaged pkgconfig 2.0.2 (465ms) #> ℹ Building pkgconfig 2.0.2 #> ✔ Built pkgconfig 2.0.2 (836ms) #> ✔ Installed pkgconfig 2.0.2 (github::cran/pkgconfig@d892880) (1s) #> ✔ Summary: 1 new in 1.9s #> # A data frame: 1 × 32 #> library package title version license imports suggests needscompilation #> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <lgl> #> 1 /tmp/RtmpVe0z… pkgcon… Priv… 2.0.2 MIT + … utils covr, t… FALSE #> # ℹ 24 more variables: repository <chr>, remotetype <chr>, remotehost <chr>, #> # remoterepo <chr>, remoteusername <chr>, remotepkgref <chr>, #> # remoteref <chr>, remotesha <chr>, built <chr>, depends <chr>, #> # linkingto <chr>, enhances <chr>, md5sum <chr>, platform <chr>, #> # priority <chr>, biocviews <chr>, sysreqs <chr>, ref <chr>, type <chr>, #> # status <chr>, rversion <chr>, sources <list>, repotype <chr>, deps <list>
Now update.
library(pkgdepends)
prop2 <- new_pkg_installation_proposal("pkgconfig", config = config)
prop2$set_solve_policy("upgrade")
prop2$solve()
prop2$download()
prop2$install()
lib_status(new_lib)
#> ℹ No downloads are needed, 1 pkg (6.08 kB) is cached #> ℹ Building pkgconfig 2.0.3 #> ✔ Built pkgconfig 2.0.3 (836ms) #> ✔ Installed pkgconfig 2.0.3 (1s) #> ✔ Summary: 1 updated in 1.9s #> # A data frame: 1 × 31 #> library package title version license imports suggests needscompilation #> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <lgl> #> 1 /tmp/RtmpVe0z… pkgcon… Priv… 2.0.3 MIT + … utils covr, t… FALSE #> # ℹ 23 more variables: repository <chr>, built <chr>, remotetype <chr>, #> # remotepkgref <chr>, remoteref <chr>, remoterepos <chr>, #> # remotepkgplatform <chr>, remotesha <chr>, depends <chr>, linkingto <chr>, #> # enhances <chr>, md5sum <chr>, platform <chr>, priority <chr>, #> # biocviews <chr>, sysreqs <chr>, ref <chr>, type <chr>, status <chr>, #> # rversion <chr>, sources <list>, repotype <chr>, deps <list>