1

When I run R (even as a headless Rscript loading zero libraries) I occasionally see

This is package 'modeest' written by P. PONCET.
For a complete list of functions, use 'library(help = "modeest")' or 'help.start()'.

It's polluting output of my log files. While I find it useful for a few things, I rarely load it. How can I prevent it from spewing messages in this case? I know if I actually load a library I can suppressPackageStartupMessages, but this message appears even without loading any packages.

It could be that I every time I see this I am calling a function that is part of a package that has a dependency on a package which has a dependency on modeest (at least somewhere in the daisy chain), even if I don't use library(...).

Steps to reproduce:

  1. install modeest package
  2. write a package with a function that imports a function from modeest
  3. write another package with a function that depends on an unrelated (to modeest) function in the package mentioned in step 2
  4. call a function from the package from step 3 either with package::func(arg) or library(package); func(arg) that doesn't depend on modeest anywhere.
wdkrnls
  • 4,548
  • 7
  • 36
  • 64
  • Maybe some ideas here: http://stackoverflow.com/questions/6279808/r-suppress-startupmessages-from-dependency or here: http://stackoverflow.com/questions/8681688/disable-messages-upon-loading-package-in-r. A [reproduicble example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) would be helpful to really solving your problem. – MrFlick Mar 09 '17 at 15:49
  • The first stackoverflow question you link to is closer to the mark. However, the solution says to use `importFrom`. I do that exclusively for all my packages. – wdkrnls Mar 09 '17 at 15:59
  • 1
    Okay, checked again: The author seems to recognise the problem [according to an explanatory comment](https://github.com/paulponcet/modeest/blob/7d0e1d36ce17bc051257bcd8c45e44a8d320d790/R/zzz.R#L10) … and then does nothing about it. So, I’ll go back to my initial assessment: shout at the author (= file a bug report), this is bad behaviour and should be fixed in the package. – Konrad Rudolph Mar 09 '17 at 16:13

1 Answers1

1

Correct; the behaviour is caused by the fact that packageStartupMessage is called in the wrong package hook.

This is a bug. I’ve submitted a pull request to fix the bug.

Unfortunately short of this fix there isn’t much that can be done to avoid this. — One thing would be to hotpatch base::packageStartupMessage before loading any other packages via assignInNamespace. This should really be a last resort though.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214