[Rd] PATCH: library(..., quietly=TRUE) still outputs "Loading required package: ..." (forgot to pass down 'quietly')

Henrik Bengtsson henrik.bengtsson at ucsf.edu
Sat May 9 22:57:12 CEST 2015


Calling library(..., quietly=TRUE) may still output:

   Loading required package: <other pkg>

in some cases, e.g.

> library("R.utils", quietly=TRUE)
Loading required package: R.methodsS3
[...]

I traced this to base:::.getRequiredPackages2(), which forgets to pass
'quietly' to an internal library() call:

if (!attached) {
    if (!quietly)
        packageStartupMessage(gettextf("Loading required package: %s",
          pkg), domain = NA)
    library(pkg, character.only = TRUE, logical.return = TRUE,
        lib.loc = lib.loc) || stop(gettextf("package %s could not be loaded",

        sQuote(pkg)), call. = FALSE, domain = NA)
}

It's from that library() call the message is generated.


Here's a patch:

$ svn diff src\library\base\R\library.R
Index: src/library/base/R/library.R
===================================================================
--- src/library/base/R/library.R        (revision 68345)
+++ src/library/base/R/library.R        (working copy)
@@ -871,7 +871,7 @@
                 packageStartupMessage(gettextf("Loading required package: %s",
                                                pkg), domain = NA)
             library(pkg, character.only = TRUE, logical.return = TRUE,
-                    lib.loc = lib.loc) ||
+                    lib.loc = lib.loc, quietly = quietly) ||
                 stop(gettextf("package %s could not be loaded", sQuote(pkg)),
                      call. = FALSE, domain = NA)
         }

I can submit it via http://bugs.r-project.org/ if preferred.


Thanks,

Henrik



More information about the R-devel mailing list