From 8d272438fe2a6b51023c1a7dd9030889222ae396 Mon Sep 17 00:00:00 2001 From: JJ Allaire Date: Fri, 4 Oct 2013 12:36:37 -0400 Subject: [PATCH] don't include suggests packages in dependencies and document how to work around this --- R/dependencies.R | 44 ++++++++++++++++++++++++++---------------- man/appDependencies.Rd | 31 ++++++++++++++++++++--------- 2 files changed, 49 insertions(+), 26 deletions(-) diff --git a/R/dependencies.R b/R/dependencies.R index dd7b20c..5a26ac6 100644 --- a/R/dependencies.R +++ b/R/dependencies.R @@ -1,5 +1,3 @@ - - #' Detect Application Dependencies #' #' Recursively detect all package dependencies for an application. This function @@ -8,19 +6,28 @@ #' packages they depend on. #' @param appDir Directory containing application. Defaults to current working #' directory. -#' @return Chracter vector with a list of recursive package dependencies for the -#' application. -#' @details -#' Dependencies are determined by parsing application source code and looking -#' for calls to \code{library}, \code{require}, \code{::}, and \code{:::}. -#' -#' If your application has a package dependency that is not detected you can -#' ensure that it is detected by inserting a call to \code{library} or -#' \code{require} with the appropriate package(s). -#' -#' Recursive dependencies are detected by examining the \code{Depends}, -#' \code{Imports}, \code{LinkingTo}, and \code{Suggests} fields of the -#' packages immediately dependend on by the application. +#' @return Character vector with a list of recursive package dependencies for +#' the application. +#' @details Dependencies are determined by parsing application source code and +#' looking for calls to \code{library}, \code{require}, \code{::}, and +#' \code{:::}. +#' +#' Recursive dependencies are detected by examining the \code{Depends}, +#' \code{Imports}, and \code{LinkingTo} fields of the packages immediately +#' dependend on by the application. +#' +#' @note Since the \code{Suggests} field is not included when determining +#' recursive dependencies of packages, it's possible that not every package +#' required to run your application will be detected. +#' +#' In this case, you can force a package to be included dependency by +#' inserting call(s) to \code{require} within your source directory. This code +#' need not actually execute, for example you could create a standalone file +#' named \code{dependencies.R} with the following code: \cr \cr +#' \code{require(xts)} \cr \code{require(colorspace)} \cr +#' +#' This will force the \code{xts} and \code{colorspace} packages to be +#' installed along with the rest of your application when it is deployed. #' @examples #' \dontrun{ #' @@ -45,8 +52,11 @@ appDependencies <- function(appDir = getwd()) { # then calculate recursive dependencies available <- availableCRANSourcePackages() - which <- c("Depends", "Imports", "LinkingTo", "Suggests") - depsList <- tools::package_dependencies(pkgs, available, recursive=TRUE) + which <- c("Depends", "Imports", "LinkingTo") + depsList <- tools::package_dependencies(pkgs, + available, + which, + recursive=TRUE) # flatten the list deps <- unlist(depsList, recursive=TRUE, use.names=FALSE) diff --git a/man/appDependencies.Rd b/man/appDependencies.Rd index 10c37e1..6ff6676 100644 --- a/man/appDependencies.Rd +++ b/man/appDependencies.Rd @@ -9,7 +9,7 @@ to current working directory.} } \value{ - Chracter vector with a list of recursive package + Character vector with a list of recursive package dependencies for the application. } \description{ @@ -24,15 +24,28 @@ code and looking for calls to \code{library}, \code{require}, \code{::}, and \code{:::}. - If your application has a package dependency that is not - detected you can ensure that it is detected by inserting - a call to \code{library} or \code{require} with the - appropriate package(s). - Recursive dependencies are detected by examining the - \code{Depends}, \code{Imports}, \code{LinkingTo}, and - \code{Suggests} fields of the packages immediately - dependend on by the application. + \code{Depends}, \code{Imports}, and \code{LinkingTo} + fields of the packages immediately dependend on by the + application. +} +\note{ + Since the \code{Suggests} field is not included when + determining recursive dependencies of packages, it's + possible that not every package required to run your + application will be detected. + + In this case, you can force a package to be included + dependency by inserting call(s) to \code{require} within + your source directory. This code need not actually + execute, for example you could create a standalone file + named \code{dependencies.R} with the following code: \cr + \cr \code{require(xts)} \cr \code{require(colorspace)} + \cr + + This will force the \code{xts} and \code{colorspace} + packages to be installed along with the rest of your + application when it is deployed. } \examples{ \dontrun{