Hi, I am writing a package that Imports several other packages. One of my imported packages eventually imports (through a chain of dependencies) "lifecycle", and another eventually imports "rlang". Both "rlang" and "lifecycle" define and export functions called "last_warnings".? As a result, when I first execute "library(MYPACKAGE)" in a script, I get a warning of the form ? " replacing previous import 'lifecycle::last_warnings' by 'rlang::last_warnings' when loading 'tibble' " I don't want the users of MYPACKAGE to have to see this warning (since I know it will spook novices). Is there anything I can do with Imports, Depends, or something else to prevent this warning from occurring? (I know that I can suppress warnings in each script, but I also don't want to explain to my users that they have to do that. Note that I have tried reversing the order of the two functions that I import in the Imports declaration in the DESCRIPTION file, to no effect. I also only use one function from each of the two imported pakages, and they are explicitly listed in importFrom directives in the NAMESPACE file. Thank in advance, ? Kevin
[R-pkg-devel] function name conflict
3 messages · Ivan Krylov, Kevin Coombes
On Tue, 12 Apr 2022 13:29:58 -0400
"Kevin R. Coombes" <kevin.r.coombes at gmail.com> wrote:
I also only use one function from each of the two imported pakages, and they are explicitly listed in importFrom directives in the NAMESPACE file.
This should be the right thing to do: list them in Imports and either use importFrom() or qualify the names of the functions you use with their namespaces; but don't list them in Depends. Are you sure you're not importing some other package (or listing it in Depends) that, in turn, Depends on rlang and/or lifecycle, bringing them into your namespace too? Can you show us the code?
Best regards, Ivan
Thanks for the answer. In the process of going back to try making a minimal example, I realized that the problem isn't my package; it already occurs in one of the packages I import. (I could have sworn I checked this previously, but apparently missed the true culprit.) In any event, I'll report a bug to them and suggest more careful use of importFrom to get around it. Best, ? Kevin
On 4/12/2022 1:50 PM, Ivan Krylov wrote:
On Tue, 12 Apr 2022 13:29:58 -0400 "Kevin R. Coombes" <kevin.r.coombes at gmail.com> wrote:
I also only use one function from each of the two imported pakages, and they are explicitly listed in importFrom directives in the NAMESPACE file.
This should be the right thing to do: list them in Imports and either use importFrom() or qualify the names of the functions you use with their namespaces; but don't list them in Depends. Are you sure you're not importing some other package (or listing it in Depends) that, in turn, Depends on rlang and/or lifecycle, bringing them into your namespace too? Can you show us the code?