in R/R/sqlPackage.R [2038:2089]
sqlSyncAndCheckInstalledPackages <- function(hodbc, packages, user = "", queryUser, scope = "PRIVATE", languageName)
{
scopeint <- parseScope(scope)
externalLibraryIds <- sqlQueryExternalLibraryId(hodbc, packages, scopeint, queryUser, languageName)
# sp_execute_external_script will first install packages to the library path
# and the run R function to check if packages installed
#
checkdf <- sqlRemoteExecuteFun(hodbc, findPackages, packages, scopeint, asuser = user, languageName = languageName)
setupFailures <- sqlQueryExternalLibrarySetupErrors(hodbc, externalLibraryIds, queryUser)
# issue specific errors for packages that failed to install to the library path
#
if((!is.null(setupFailures)) && (nrow(setupFailures) > 0))
{
errors <- mapply(
function(packageName, errorCode, errorMessage)
{
sprintf("failed to install package (%s) to library path: user='%s', scope='%s', error code='%s', error message='%s'",
packageName, user, scope, as.hexmode(errorCode), errorMessage)
},
setupFailures[,"name"], setupFailures[,"error_code"], setupFailures[,"error_message"]
)
stop(paste(errors, collapse = " ; "), call. = FALSE)
}
# issue generic errors for packages not found in library path
#
failedPackages <- unlist(mapply(
function(packageName,found)
{
if (found == FALSE)
{
return (packageName)
}
return (NULL)
},
checkdf[,"Package"], checkdf[,"Found"],
SIMPLIFY=TRUE,
USE.NAMES=FALSE
))
if(length(failedPackages) > 0)
{
stop(sprintf("failed to install packages (%s) to library path: user='%s', scope='%s'", paste(failedPackages, collapse = ", "), user, scope), call. = FALSE)
}
return(packages)
}