Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is BiocManager emitting messages on package load? #94

Open
LTLA opened this issue Apr 8, 2021 · 8 comments
Open

Why is BiocManager emitting messages on package load? #94

LTLA opened this issue Apr 8, 2021 · 8 comments

Comments

@LTLA
Copy link

LTLA commented Apr 8, 2021

The change in 1fed528 is causing emission of annoying messages in all packages that Import BiocManager. For example, BiocStyle imports BiocManager, and this is causing all my vignettes and reports generated in an interactive session to contain this message:

Bioconductor version 3.13 (BiocManager 1.30.12), ?BiocManager::install for help

in every location where I have library(BiocStyle). I didn't bother to suppressPackageStartupMessages() because BiocStyle was not emitting any messages previously. One could argue that I should suppress these messages, but then I would say that I shouldn't have to see this message in the first place, especially if I'm not using BiocManager directly. Why the chattiness?

@hpages
Copy link
Contributor

hpages commented Apr 8, 2021

I just noticed that too earlier today after doing library(BiocStyle) on one of the build machines. Looks like the .onAttach hook was replaced by an .onLoad hook (see commit 1fed528). Not sure why.

As a general rule I don't think .onLoad hooks should print messages.

@LiNk-NY
Copy link
Contributor

LiNk-NY commented Apr 8, 2021

Any insights, Martin? @mtmorgan Thanks!

@mtmorgan
Copy link
Collaborator

mtmorgan commented Apr 8, 2021

The banner can be useful in bug reports, and the 'best practice' recommendation for use (e.g., BiocManager::version()) doesn't attach the package. So it made sense to have the message in .onLoad rather than .onAttach.

I'm not sure why a package would import BiocManager: package installation shouldn't be something a package attempts to 'do' for the user.

@LTLA
Copy link
Author

LTLA commented Apr 8, 2021

BiocStyle imports BiocManager to get version(), so that Biocpkg() and friends can point to the correct URL.

@hpages
Copy link
Contributor

hpages commented Apr 9, 2021

Maybe best practice should be to explicitly library() the package before using it interactively? That's kind of the standard thing to do, for any package.

@mtmorgan
Copy link
Collaborator

mtmorgan commented Apr 9, 2021

I chose not to emphasize using library() because I wanted commands that the user sees to be fully resolved and therefore not subject to namespace collisions -- the natural interpretation of install(), version(), etc resolved with BiocManager::...() seem like a better choice than some name mangling bm_installl() etc.

I will revisit this so that version() etc returns an object that is a version and hence computable, but prints with information about package version etc. I will remove the startup message.

@HenrikBengtsson
Copy link
Contributor

You could condition the message based on how the package was loaded by looking at sys.calls()[1]. For instance, show it if user called it via a BiocManager::..., library(BiocManager), ...

@mtmorgan
Copy link
Collaborator

mtmorgan commented Apr 13, 2021

Thanks @HenrikBengtsson; I shy away from that level of complexity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants