----- Original Message ----- > The thing that happens during the check is that the methods package is > not among the automatically loaded and attached packages. > > When the pkgB packages is attached, the Namespaces of pkgA and methods > are loaded but not attached. > > Note that one of the checks tells you: > > "A namespace must be able to be loaded with just the base namespace > loaded: otherwise if the namespace gets loaded by a saved object, the > session will be unable to start." > > > If you like to see into the details more easily, just start R with > > R R_DEFAULT_PACKAGES=NULL > and then try to > library("pkgB") > and you are able to reproduce the check messages.
yep, but .onLoad code can be written as a = new("A") length(a) the error is on length(a) -- after methods::new has been found. Also, inserting a browser() call in .onLoad and then Browse[1]> names(getNamespaceInfo(parent.env(environment()), "imports")) [1] "base" "methods" "pkgA" "pkgA" or Browse[1]> findFunction("loadMethod") [[1]] <environment: 0x752d90> attr(,"name") [1] "imports:pkgB" shows that the methods name space is where it should be. It is the dispatch on the promoted length (in pkgA) that is awry. Martin > > You can avoid n-1 Warnings/Errors in the checks by adding > library("methods") > in your .onLoad function, but of course you cannot get rid of the > check > that checks that the package can be loaded with the base namespace > only. > > Best, > Uwe Ligges > > > > > > > > > On 15.10.2011 02:46, Hervé Pagès wrote: > > Hi, > > > > This strange warning happen sometimes when running 'R CMD check': > > > > * checking whether the package can be loaded with stated > > dependencies > > ... WARNING > > > > Error : .onLoad failed in loadNamespace() for ‘pkgB’, details: > > call: length(new("A")) > > error: could not find function "loadMethod" > > Error: package/namespace load failed for ‘pkgB’ > > Execution halted > > > > It looks like this package (or one of its dependent packages) has an > > unstated dependence on a standard package. All dependencies must be > > declared in DESCRIPTION. > > See the information on DESCRIPTION files in the chapter ‘Creating R > > packages’ of the ‘Writing R Extensions’ manual. > > > > The same warning is reported during the 2 next checks: > > > > * checking whether the package can be unloaded cleanly ... WARNING > > <same error here> > > * checking whether the namespace can be loaded with stated > > dependencies > > ... WARNING > > <same error here> > > > > It seems to happen when pkgB has code in its .onLoad hook that > > tries to call a method defined in pkgA (pkgB imports pkgA) on an > > object > > 'x' that is an instance of a class defined in pkgA. For some obscure > > reason it seems that, at the time the .onLoad hook is executed, the > > methods package (which is imported in both packages) is not working > > properly. > > > > I've put 2 toy packages here that illustrate the problem: > > > > https://rapidshare.com/files/4043144391/pkgA_1.0.tar.gz > > > > https://rapidshare.com/files/1959508331/pkgB_1.0.tar.gz > > > > I'm using R version 2.14.0 alpha (2011-10-10 r57211). > > > > The .onLoad hook in pkgB is: > > > > .onLoad <- function(libname, pkgname) > > { > > showMethods("length") > > length(new("A")) > > } > > > > Class A and the length method for this class is defined in pkgA. > > > > Because of the showMethods("length") statement, you should see this > > when running R CMD check pkgB_1.0.tar.gz: > > > > * checking whether the package can be loaded with stated > > dependencies > > ... WARNING > > Function: length (package base) > > x="A" > > > > Error : .onLoad failed in loadNamespace() for ‘pkgB’, details: > > call: length(new("A")) > > error: could not find function "loadMethod" > > Error: package/namespace load failed for ‘pkgB’ > > Execution halted > > > > Any insight on this would be appreciated. > > > > Thanks, > > H. > > > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel