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

Martin Maechler maechler at lynne.stat.math.ethz.ch
Mon May 11 17:53:40 CEST 2015


>>>>> Henrik Bengtsson <henrik.bengtsson at ucsf.edu>
>>>>>     on Sat, 9 May 2015 13:57:12 -0700 writes:

    > 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.

No. It's easier that way -- already in the R-devel sources,
thank you Henrik.

Martin

    > Thanks,
    > Henrik



More information about the R-devel mailing list