From henrik.bengtsson at ucsf.edu  Sat May  9 22:57:12 2015
From: henrik.bengtsson at ucsf.edu (Henrik Bengtsson)
Date: Sat, 9 May 2015 13:57:12 -0700
Subject: [Rd] PATCH: library(...,
 quietly=TRUE) still outputs "Loading required package: ..." (forgot
 to pass down 'quietly')
Message-ID: <CAFDcVCRTQPHR1NB1Cy-gfw8NYSQhAL_58nHvVNojiyr9RXDr3g@mail.gmail.com>

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



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