[Rd] library(grid) : .First.lib fails (PR#3347)
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Jun 27 08:57:21 MEST 2003
On Fri, 27 Jun 2003 arnima at u.washington.edu wrote:
> I'm having problems loading the 'grid' package when it has been detached
> earlier in the same session:
>
> > library(grid)
> > detach("package:grid")
> > library(grid)
> Error in .Call("L_initGrid", PACKAGE = "grid") :
> .Call function name not in load table
> Error in library(grid) : .First.lib failed
>
> This bug was mentioned on r-help some time ago
> (www.stat.math.ethz.ch/pipermail/r-help/2002-January/016904.html), but I
> don't think it has entered the bug tracking system yet. The bug is
> relevant for me since it crashes functions I use for package maintenance.
[That has nothing to do with this: it was a broken Windows build of R
1.4.0 on CRAN, and that message says that it was fixed in the next build.]
Basically, what you are doing is not supported. Don't detach packages you
want to re-use. With the sort of amount of memory people have these days,
it makes little sense ever to detach packages. (It does not unload the DLL
in general, and grid is a rare exception.)
The specific issue is that grid contains a .Last.lib which does unload the
DLL but does not unregister it. It needs to be
.Last.lib <-function(libpath) {
if (.grid.loaded) {
# Kill all existing devices to avoid replay
# of display list which tries to run grid code
# Not very friendly to other registered graphics systems
# but its safety first for now
graphics.off()
.Call("L_killGrid", PACKAGE="grid")
dyn.unload(paste(libpath, "libs",
paste("grid", .Platform$dynlib.ext, sep=""),
sep=.Platform$file.sep))
.dynLibs(.Dyn.libs[-match("grid", .dynLibs()])
}
}
and note the comment there. (Paul: please use file.path is the dyn.unload
call.)
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel
mailing list