From f.harrell at vanderbilt.edu  Tue Jun  1 21:03:30 2004
From: f.harrell at vanderbilt.edu (Frank E Harrell Jr)
Date: Tue Jun  1 21:02:30 2004
Subject: [Rd] Problem with .First.lib while running R CMD check
In-Reply-To: <16572.29688.125672.489994@gargle.gargle.HOWL>
References: <40BB6107.5040001@vanderbilt.edu>	<16572.8966.59739.966023@gargle.gargle.HOWL>	<40BC18A1.5070005@vanderbilt.edu>
	<16572.29688.125672.489994@gargle.gargle.HOWL>
Message-ID: <40BCD302.4060208@vanderbilt.edu>

Martin Maechler wrote:
>>>>>>"Frank" == Frank E Harrell <f.harrell@vanderbilt.edu>
>>>>>>    on Tue, 01 Jun 2004 07:48:17 +0200 writes:
> 
> 
>     Frank> Martin Maechler wrote:
>     >>>>>>> "Frank" == Frank E Harrell <f.harrell@vanderbilt.edu>
>     >>>>>>> on Mon, 31 May 2004 18:44:55 +0200 writes:
>     >> 
>     >> 
>     Frank> I am having difficulty running R CMD check using the
>     Frank> 30May04 version of R-devel and a new version of the
>     Frank> Hmisc package:
>     >> 
>     Frank> * checking S3 generic/method consistency ... WARNING
>     Frank> Error in .tryQuietly({ : Error in library(package, lib.loc = lib.loc, 
>     Frank> character.only = TRUE, verbose = FALSE) :
>     Frank> .First.lib failed
>     Frank> Execution halted
>     >> 
>     Frank> See section 'Generic functions and methods' of the
>     Frank> 'Writing R Extensions' manual.
>     >> 
>     >> I'm not sure, but I'd guess it's simply the last line of your
>     >> .First.lib. that fails, i.e.,
>     >> library.dynam("Hmisc", pkg, lib)
>     >> which fails loading the C/Fortran code.
>     >> I've had similar experiences.  The 'R CMD check' error message
>     >> is definitely ``sub optimal''.
>     >> 
>     >> Simply try (in R-devel)
>     >> 
>     >> library(Hmisc, lib.loc="~/R/Hmisc.Rcheck")
>     >> 
>     >> This should give a much better error message.
>     >> Let us know if this helped.
>     >> 
>     >> Regards, Martin
> 
>     Frank> Thanks Martin.  Here's what I get:
> 
>     >> library(Hmisc,lib.loc="~/R/Hmisc.Rcheck")
>     Frank> Hmisc library by Frank E Harrell Jr
> 
>     Frank> Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview')
>     Frank> to see overall documentation.
> 
>     Frank> Hmisc redefines [.factor to drop unused levels of factor variables
>     Frank> when subscripting. To prevent this behaviour, issue the command
>     Frank> options(drop.unused.levels=F).
> 
>     Frank> Error in dyn.load(x, as.logical(local), as.logical(now)) :
>     Frank> unable to load shared library 
>     Frank> "/home/harrelfe/R/Hmisc.Rcheck/Hmisc/libs/Hmisc.so":
>     Frank> libR.so: cannot open shared object file: No such file or directory
> 	   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> this probably is the clue :  Hmisc.so expects an libR.so
> which is what you get when you do ......./configure --enable-shared
> and make for building R itself.
> 
> It looks like your version of R-devel
> hasn't successfully been built with the ..shared option.
> But when using it to build packages, it *does* assume the
> 'shared R' (libR.so in unix) to be available.
> 
> [or Hmisc.so itself or its underlying *.o files were built with 
>  a non-shared (i.e. default) version of R ?]
> 
> If it the former (and incomplete shared installation) I'd
> consider wiping that out and rebuild R afresh -- shared or not --
> test R ("make check" or even "make check-all") and when
> successful, rebuild Hmisc {removing at least  Hmisc/src/*o
> beforehand!} with that version of R.
> 
> Martin

Thanks very much Martin.  I think you've hit on it.  The problem seems 
to have to do with the order in which I install Hmisc using regular 
(non-shared) R (installed the usual Debian way) with regard to when I 
run CMD check under R-devel.  I configured R-devel using --enable-shared 
(if this matters) and ran R-devel CMD check "fresh" and all seems to be 
well.  Thanks for your insight.  In the future I think I'll just remove 
the *.o files from regular R before running CMD check.  I am surprised 
that R-devel and R 1.9 are inconsistent on this point.  -Frank

> 
>     Frank> Error in library(Hmisc, lib.loc = "~/R/Hmisc.Rcheck") :
>     Frank> .First.lib failed
> 
>     Frank> Since Hmisc.so is in the right place:
> 
>     Frank> ~/R/Hmisc.Rcheck/Hmisc/libs harrelfe:ls -la
>     Frank> total 48
>     Frank> drwxr-xr-x    2 harrelfe harrelfe     4096 May 31 18:31 .
>     Frank> drwxr-xr-x   10 harrelfe harrelfe     4096 May 31 18:34 ..
>     Frank> -rwxr-xr-x    1 harrelfe harrelfe    37524 May 31 18:31 Hmisc.so
> 
>     Frank> I don't understand the problem.  The same Hmisc.so (under 
>     Frank> /usr/local/lib/R/site-library) loads fine under R 1.9.
> 
>     Frank> Frank
> 
> 


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University


[Rd] Problem with .First.lib while running R CMD check
Frank E Harrell Jr