From maechler at lynne.stat.math.ethz.ch  Mon May 11 17:53:40 2015
From: maechler at lynne.stat.math.ethz.ch (Martin Maechler)
Date: Mon, 11 May 2015 17:53:40 +0200
Subject: [Rd] PATCH: library(...,
 quietly=TRUE) still outputs "Loading required package: ..." (forgot
 to pass down 'quietly')
In-Reply-To: <CAFDcVCRTQPHR1NB1Cy-gfw8NYSQhAL_58nHvVNojiyr9RXDr3g@mail.gmail.com>
References: <CAFDcVCRTQPHR1NB1Cy-gfw8NYSQhAL_58nHvVNojiyr9RXDr3g@mail.gmail.com>
Message-ID: <21840.53380.90208.47505@stat.math.ethz.ch>

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



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