Skip to content
Snippets Groups Projects
Commit 050ce64c authored by Florian Angerer's avatar Florian Angerer
Browse files

Fix: do not provoke error when caching if installation failed.

parent 37f09531
No related branches found
No related tags found
No related merge requests found
......@@ -725,9 +725,29 @@ fastr_error_log_size <- function() {
install.pkg <- function(pkgname) {
error_log_size <- fastr_error_log_size()
if (run.mode == "system") {
pkg.cache.install(pkgname, function() system.install(pkgname))
system.install.wrapper <- function() {
tryCatch(
system.install(pkgname)
, error = function(e) {
log.message(e$message)
return (1)
}, warning = function(e) {
log.message(e$message)
# According to the documentation of 'system2', a warning will provide a status field.
return (e$status)
})
}
pkg.cache.install(pkgname, system.install.wrapper)
} else if (run.mode == "internal") {
pkg.cache.install(pkgname, function() install.packages(pkgname, type="source", lib=lib.install, INSTALL_opts="--install-tests"))
internal.install.wrapper <- function() {
tryCatch(
install.packages(pkgname, type="source", lib=lib.install, INSTALL_opts="--install-tests")
, error = function(e) {
log.message(e$message)
return (1)
})
}
pkg.cache.install(pkgname, internal.install.wrapper)
} else if (run.mode == "context") {
stop("context run-mode not implemented\n")
}
......@@ -740,8 +760,12 @@ install.pkg <- function(pkgname) {
pkg.cache.install <- function(pkgname, install.cmd) {
is.cached <- pkg.cache.get(pkgname, lib=lib.install)
if (!is.cached) {
install.cmd()
pkg.cache.insert(pkgname, lib.install)
res <- install.cmd()
# 0L stands for success
if (res == 0L) {
pkg.cache.insert(pkgname, lib.install)
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment