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 × 37 #> 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.1 MIT + … TRUE #> 2 color… stan… FALSE FALSE OK colors… 2.1-0 BSD_3_… TRUE #> 3 fansi stan… FALSE FALSE OK fansi 1.0.4 GPL-2 … TRUE #> 4 farver stan… FALSE FALSE OK farver 2.1.1 MIT + … TRUE #> 5 ggplo… stan… TRUE TRUE OK ggplot2 3.4.3 MIT + … FALSE #> 6 glue stan… FALSE FALSE OK glue 1.6.2 MIT + … TRUE #> 7 gtable stan… FALSE FALSE OK gtable 0.3.4 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.3 MIT + … FALSE #> # ℹ 18 more rows #> # ℹ 28 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>, 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.4.3 [new][bld][dl] (2.19 MB) #> ├─cli 3.6.1 [new][bld][cmp] #> ├─glue 1.6.2 [new][bld][cmp] #> ├─gtable 0.3.4 [new][bld][dl] (130.10 kB) #> │ ├─cli #> │ ├─glue #> │ ├─lifecycle 1.0.3 [new][bld][dl] (106.85 kB) #> │ │ ├─cli #> │ │ ├─glue #> │ │ └─rlang 1.1.1 [new][bld][cmp] #> │ └─rlang #> ├─isoband 0.2.7 [new][bld][cmp][dl] (1.59 MB) #> ├─lifecycle #> ├─MASS 7.3-60 < 7.3-60.1 [old] #> ├─mgcv 1.8-42 < 1.9-0 [old] #> │ ├─nlme 3.1-162 < 3.1-163 [old] #> │ │ └─lattice 0.21-8 #> │ └─Matrix 1.5-4.1 < 1.6-1.1 [old] #> │ └─lattice #> ├─rlang #> ├─scales 1.2.1 [new][bld][dl] (270.61 kB) #> │ ├─farver 2.1.1 [new][bld][cmp][dl] (1.27 MB) #> │ ├─labeling 0.4.3 [new][bld][dl] (10.17 kB) #> │ ├─lifecycle #> │ ├─munsell 0.5.0 [new][bld][dl] (182.65 kB) #> │ │ └─colorspace 2.1-0 [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.4 [new][bld][cmp][dl] (482.06 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.3 [new][bld][cmp][dl] (241.41 kB) #> │ │ └─vctrs 0.6.3 [new][bld][cmp][dl] (967.34 kB) #> │ │ ├─cli #> │ │ ├─glue #> │ │ ├─lifecycle #> │ │ └─rlang #> │ ├─pkgconfig 2.0.3 [new][bld][dl] (6.08 kB) #> │ ├─rlang #> │ └─vctrs #> ├─vctrs #> └─withr 2.5.0 [new][bld] #> #> 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: 28 × 37 #> 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.4.3.… MIT + … TRUE #> 2 cli stan… FALSE FALSE OK cli 3.6.1 MIT + … TRUE #> 3 color… stan… FALSE FALSE OK colors… 2.1-0 BSD_3_… TRUE #> 4 fansi stan… FALSE FALSE OK fansi 1.0.4 GPL-2 … TRUE #> 5 farver stan… FALSE FALSE OK farver 2.1.1 MIT + … TRUE #> 6 glue stan… FALSE FALSE OK glue 1.6.2 MIT + … TRUE #> 7 gtable stan… FALSE FALSE OK gtable 0.3.4 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.3 MIT + … FALSE #> # ℹ 18 more rows #> # ℹ 28 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>, cache_status <chr>, #> # sysreqs_packages <list>, sysreqs_pre_install <chr>, … #> # ℹ Use `print(n = ...)` to see more rows
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: 19 × 37 #> 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.6.0.… MIT + … NA #> 2 callr stan… FALSE FALSE OK callr 3.7.3 MIT + … FALSE #> 3 cli stan… FALSE FALSE OK cli 3.6.1 MIT + … TRUE #> 4 crayon stan… FALSE FALSE OK crayon 1.5.2 MIT + … FALSE #> 5 curl stan… FALSE FALSE OK curl 5.0.2 MIT + … TRUE #> 6 desc stan… FALSE FALSE OK desc 1.4.2 MIT + … FALSE #> 7 filel… stan… FALSE FALSE OK filelo… 1.0.2 MIT + … TRUE #> 8 glue stan… FALSE FALSE OK glue 1.6.2 MIT + … TRUE #> 9 jsonl… stan… FALSE FALSE OK jsonli… 1.8.7 MIT + … TRUE #> 10 lpSol… stan… FALSE FALSE OK lpSolve 5.6.19 LGPL-2 TRUE #> 11 pkgbu… stan… FALSE FALSE OK pkgbui… 1.4.2 MIT + … FALSE #> 12 pkgca… stan… FALSE FALSE OK pkgcac… 2.2.0.1 MIT + … TRUE #> 13 prett… stan… FALSE FALSE OK pretty… 1.1.1 MIT + … FALSE #> 14 proce… stan… FALSE FALSE OK proces… 3.8.2 MIT + … TRUE #> 15 ps stan… FALSE FALSE OK ps 1.7.5 MIT + … TRUE #> 16 R6 stan… FALSE FALSE OK R6 2.5.1 MIT + … FALSE #> 17 rappd… stan… FALSE FALSE OK rappdi… 0.3.3 MIT + … TRUE #> 18 rproj… stan… FALSE FALSE OK rprojr… 2.0.3 MIT + … FALSE #> 19 zip stan… FALSE FALSE OK zip 2.3.0 MIT + … TRUE #> # ℹ 28 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>, 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 28 pkgs (22.46 MB), 5 (1.60 MB) cached #> ✔ Got gtable 0.3.4 (source) (130.10 kB) #> ✔ Got cli 3.6.1 (source) (567.29 kB) #> ✔ Got fansi 1.0.4 (source) (482.06 kB) #> ✔ Got magrittr 2.0.3 (source) (267.07 kB) #> ✔ Got pkgconfig 2.0.3 (source) (6.08 kB) #> ✔ Got lattice 0.21-8 (source) (589.33 kB) #> ✔ Got colorspace 2.1-0 (source) (2.12 MB) #> ✔ Got nlme 3.1-163 (source) (848.98 kB) #> ✔ Got glue 1.6.2 (source) (106.51 kB) #> ✔ Got vctrs 0.6.3 (source) (967.34 kB) #> ✔ Got labeling 0.4.3 (source) (10.17 kB) #> ✔ Got RColorBrewer 1.1-3 (source) (11.64 kB) #> ✔ Got R6 2.5.1 (source) (63.42 kB) #> ✔ Got withr 2.5.0 (source) (102.09 kB) #> ✔ Got utf8 1.2.3 (source) (241.41 kB) #> ✔ Got Matrix 1.6-1.1 (source) (2.07 MB) #> ✔ Got MASS 7.3-60 (source) (561.53 kB) #> ✔ Got munsell 0.5.0 (source) (182.65 kB) #> ✔ Got tibble 3.2.1 (source) (565.98 kB) #> ✔ Got mgcv 1.9-0 (source) (1.11 MB) #> ✔ Got viridisLite 0.4.2 (source) (1.27 MB) #> ✔ Got isoband 0.2.7 (source) (1.59 MB) #> ✔ Got rlang 1.1.1 (source) (762.53 kB) #> ✔ Got Matrix 1.6-1.1 (source) (2.07 MB) #> ✔ Got pillar 1.9.0 (source) (444.53 kB) #> ✔ Got mgcv 1.9-0 (source) (1.11 MB) #> ✔ Got lifecycle 1.0.3 (source) (106.85 kB) #> ✔ Got lattice 0.21-8 (source) (589.33 kB) #> ✔ Got scales 1.2.1 (source) (270.61 kB) #> ✔ Got nlme 3.1-163 (source) (848.98 kB) #> ✔ Got ggplot2 3.4.3 (source) (2.19 MB) #> ✔ Got MASS 7.3-60.1 (source) (535.22 kB) #> ✔ Got farver 2.1.1 (source) (1.27 MB) #> # A data frame: 33 × 39 #> 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.1 MIT + … TRUE #> 2 color… stan… FALSE FALSE OK colors… 2.1-0 BSD_3_… TRUE #> 3 fansi stan… FALSE FALSE OK fansi 1.0.4 GPL-2 … TRUE #> 4 farver stan… FALSE FALSE OK farver 2.1.1 MIT + … TRUE #> 5 ggplo… stan… TRUE TRUE OK ggplot2 3.4.3 MIT + … FALSE #> 6 glue stan… FALSE FALSE OK glue 1.6.2 MIT + … TRUE #> 7 gtable stan… FALSE FALSE OK gtable 0.3.4 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.21-8 GPL (>… TRUE #> # ℹ 23 more rows #> # ℹ 30 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>, 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 (1.2s) #> ✔ Installed pkgconfig 2.0.3 (27ms) #> ✔ Summary: 1 new in 1.2s #> # A data frame: 1 × 31 #> library package title version license imports suggests needscompilation #> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <lgl> #> 1 /tmp/Rtmp3JId… 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 (381ms) #> ℹ Building pkgconfig 2.0.2 #> ✔ Built pkgconfig 2.0.2 (1.2s) #> ✔ Installed pkgconfig 2.0.2 (github::cran/pkgconfig@d892880) (24ms) #> ✔ Summary: 1 new in 1.2s #> # A data frame: 1 × 32 #> library package title version license imports suggests needscompilation #> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <lgl> #> 1 /tmp/Rtmp3JId… pkgcon… Priv… 2.0.2 MIT + … utils covr, t… FALSE #> # ℹ 24 more variables: repository <chr>, built <chr>, remotetype <chr>, #> # remotehost <chr>, remoterepo <chr>, remoteusername <chr>, #> # remotepkgref <chr>, remoteref <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>
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 (1.2s) #> ✔ Installed pkgconfig 2.0.3 (26ms) #> ✔ Summary: 1 updated in 1.2s #> # A data frame: 1 × 31 #> library package title version license imports suggests needscompilation #> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <lgl> #> 1 /tmp/Rtmp3JId… 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>