Skip to content

Improve messaging for install.packages #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/library/utils/R/packages2.R
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ install.packages <-
if(verbose) message(gettextf("files: %s",
paste(files, collapse=", \n\t")),
domain = NA)
update <- cbind(update[found, , drop=FALSE], file = files)
update <- cbind(update[found, , drop=FALSE], file = files, status = "")
if(nrow(update) > 1L) {
upkgs <- unique(pkgs <- update[, 1L])
DL <- .make_dependency_list(upkgs, available)
Expand Down Expand Up @@ -901,6 +901,7 @@ install.packages <-
## Try to figure out which
pkgs <- update[, 1L]
tss <- sub("[.]ts$", "", dir(".", pattern = "[.]ts$"))
update[!pkgs %in% tss, 4L] <- "FAIL"
failed <- pkgs[!pkgs %in% tss]
for (pkg in failed) {
## targets with failed dependencies are not made (even with -k)
Expand Down Expand Up @@ -957,10 +958,12 @@ install.packages <-
## if this times out it will leave locks behind
if(!quiet && keep_outputs)
writeLines(readLines(outfile))
if(status > 0L)
if(status > 0L){
warning(gettextf("installation of package %s had non-zero exit status",
sQuote(update[i, 1L])),
domain = NA)
update[i, 4L] <- "FAIL"
}
else if(verbose) {
cmd <- paste(c(cmd0, args), collapse = " ")
message(sprintf("%d): succeeded '%s'", i, cmd),
Expand All @@ -971,17 +974,18 @@ install.packages <-
file.copy(outfiles, outdir, overwrite = TRUE)
unlink(tmpd2, recursive = TRUE)
}
## Using stderr is the wish of PR#16420
if(!quiet && nonlocalrepos && !is.null(tmpd) && is.null(destdir))
cat("\n", gettextf("The downloaded source packages are in\n\t%s",
sQuote(normalizePath(tmpd, mustWork = FALSE))),
"\n", sep = "", file = stderr())
## update packages.html on Unix only if .Library was installed into
libs_used <- unique(update[, 2L])
if(.Platform$OS.type == "unix" && .Library %in% libs_used) {
message("Updating HTML index of packages in '.Library'")
make.packages.html(.Library)
}
## Using stderr is the wish of PR#16420
if(!quiet && nonlocalrepos && !is.null(tmpd) && is.null(destdir))
cat("\n", gettextf("Installed %d packages in\n\t%s", sum(update[, 4L] != "FAIL"),
paste(sQuote(normalizePath(libs_used, mustWork = FALSE)), collapse = "\n\t")),
"\n", sep = "", file = stderr())

} else if(!is.null(tmpd) && is.null(destdir)) unlink(tmpd, TRUE)

invisible()
Expand Down
7 changes: 4 additions & 3 deletions src/library/utils/R/unix/mac.install.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,11 @@ if(!startsWith(R.version$os, "darwin")) {
unpackPkg(foundpkgs[okp, 2L], foundpkgs[okp, 1L], lib,
lock = lock)
}
if(!quiet && sum(oklib)){
cat("\n", gettextf("Successfully installed %d binary packages in\n\t%s",
sum(oklib), lib), "\n", sep = "")
}
}
if(!quiet && !is.null(tmpd) && is.null(destdir))
cat("\n", gettextf("The downloaded binary packages are in\n\t%s", tmpd),
"\n", sep = "")
} else if(!is.null(tmpd) && is.null(destdir)) unlink(tmpd, recursive = TRUE)

invisible()
Expand Down
9 changes: 4 additions & 5 deletions src/library/utils/R/windows/install.packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,11 @@ unpackPkgZip <- function(pkg, pkgname, lib, libs_only = FALSE,
unpackPkgZip(foundpkgs[okp, 2L], foundpkgs[okp, 1L],
lib, libs_only, lock)
}
if(!quiet && sum(oklib)){
cat("\n", gettextf("Successfully installed %d binary packages in\n\t%s",
sum(oklib), normalizePath(lib, mustWork = FALSE)), "\n", sep = "")
}
}
if(!quiet && !is.null(tmpd) && is.null(destdir))
## tends to be a long path on Windows
cat("\n", gettextf("The downloaded binary packages are in\n\t%s",
normalizePath(tmpd, mustWork = FALSE)),
"\n", sep = "")
} else if(!is.null(tmpd) && is.null(destdir)) unlink(tmpd, recursive = TRUE)

invisible()
Expand Down
2 changes: 1 addition & 1 deletion src/modules/internet/internet.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ static SEXP in_do_download(SEXP args)
}

R_Busy(1);
if(!quiet) REprintf(_("trying URL '%s'\n"), url);
if(!quiet) REprintf(_("Downloading '%s'\n"), url);
SEXP agentFun, sagent;
R_FlushConsole();
agentFun = PROTECT(lang2(install("makeUserAgent"), ScalarLogical(0)));
Expand Down
2 changes: 1 addition & 1 deletion src/modules/internet/libcurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ static int download_add_url(int i, SEXP scmd, const char *mode,
curl_easy_setopt(hnd[i], CURLOPT_ACCEPT_ENCODING, "gzip, deflate");
*/

if (!quiet) REprintf(_("trying URL '%s'\n"), url);
if (!quiet) REprintf(_("Downloading '%s'\n"), url);
vmaxset(vmax);
return 0;
}
Expand Down