It seems package_dependencies
doesn't report all the dependencies,
or install.packages
is going way, way overboard.
For example, in a new install of R 3.5.0 from source on Ubuntu 16.04,
package_dependencies shows only 3 dependencies for colorspace
. But when I
install colorspace
, 22 other packages are yanked in.
$ /sdata/ftp/rlang/tdi/bin/R --vanilla
...(R announcements)
.libPaths()
[1] "/sdata/ftp/rlang/tdi/lib64/R/library"
library( tools)
avail <- available.packages( repos="https://mirrors.nics.utk.edu/cran")
package_dependencies("colorspace", recursive=TRUE, db=avail)
$colorspace
[1] "methods" "graphics" "grDevices"
install.packages("colorspace", dependencies=TRUE,
lib="/some/empty/dir",
repos="https://mirrors.nics.utk.edu/cran")
also installing the dependencies ‘zoo’, ‘Rcpp’, ‘BH’, ‘magrittr’,
‘lmtest’, ‘httpuv’, ‘mime’, ‘jsonlite’, ‘xtable’, ‘digest’,
‘htmltools’, ‘R6’, ‘sourcetools’, ‘later’, ‘promises’, ‘crayon’,
‘rlang’, ‘kernlab’, ‘mvtnorm’, ‘vcd’, ‘dichromat’, ‘shiny’, ‘shinyjs’
Why are all these packages being yanked in?
By setting dependencies=TRUE
(rather than the default value of NA
) you're getting not just imports/depends/linkingto, but also all of the suggested packages: from ?install.packages
,
... ‘TRUE’ means to use ‘c("Depends", "Imports", "LinkingTo", "Suggests")’ for ‘pkgs’ and ‘c("Depends", "Imports", "LinkingTo")’ for added dependencies: this installs all the packages needed to run ‘pkgs’, their examples, tests and vignettes (if the package author specified them correctly).
The analog for package_dependencies
is which="all"
.
length(package_dependencies("colorspace",
recursive=FALSE,which="all")$colorspace)
## 15
length(package_dependencies("colorspace",
recursive=TRUE,which="all")$colorspace)
## 1278
The reason you're getting 22 (and not 15 or 1278) new packages installed is a combination of (1) some packages are already installed (e.g. the 15 direct Suggests: dependencies include at least 6 base/recommended packages) and (2) as described above in the documentation block, install.packages()
does not apply the Suggests: requirement recursively - you get all of the direct Suggests: dependencies, but only the 2d-order dependencies required (not suggested) to make them work. Take a look at
lapply(package_dependencies("colorspace",
recursive=FALSE,which="all")$colorspace,
package_dependencies)
(shiny
and shinyjs
are the real culprits ...)
It would be nice if there were a version of package_dependencies
that gave the same results as install.packages(...,dependencies=TRUE)
, i.e. took all suggested packages at the first level but then proceeded recursively to find all required packages. (This might be a good homework assignment for an intermediate R course ...)
OK, I went a little crazy. I count 24, not 22, that should have to be installed ... ? (I looked at the difference: you're getting 23, not 22 extra packages, and the 24th is colorspace
itself ...)
a1 <- available.packages()
i1 <- installed.packages()
order1 <- package_dependencies("colorspace",
db=a1,
recursive=FALSE,
which="all")$colorspace
order2 <- plyr::llply(order1,
package_dependencies,
db=a1,
recursive=TRUE,
.progress="text")
all_pkgs <- unique(c(order1,unlist(order2,recursive=TRUE)))
base_pkgs <- rownames(i1)[!is.na(i1[,"Priority"])]
setdiff(all_pkgs,base_pkgs)