[R-sig-Geo] complex dependency of gstat on sp, R 2.4.0

Roger Bivand Roger.Bivand at nhh.no
Thu Oct 5 10:52:54 CEST 2006

On Thu, 5 Oct 2006, Edzer J. Pebesma wrote:

> Roger,
> install.packages("gstat") with 2.4 over a 2.3 library gives me the 
> following:
> ...
> ufctr.o sprow.o spswap.o stat.o submat.o userio.o utils.o vario.o 
> vario_fn.o vario_io.o vecop.o version.o writecmd.o xvalid.o   
> -L/usr/lib/R/lib -lR
> ** R
> ** data
> ** demo
> ** inst
> ** preparing package for lazy loading
> Loading required package: sp
> Error in loadNamespace(package, c(which.lib.loc, lib.loc), keep.source = 
> keep.source) :
>         in 'sp' methods for export not found: bbox, coordinates, 
> coordinates<-, coordnames, coordnames<-, gridded, polygons, polygons<-, 
> dimensions, [, transform, overlay, plot, recenter, spplot, spsample, summary
> Error: package 'sp' could not be loaded
> Execution halted
> ERROR: lazy loading failed for package 'gstat'
> ** Removing '/home/edzer/S/library/gstat'
> ** Restoring previous '/home/edzer/S/library/gstat'
> The downloaded packages are in
>         /tmp/RtmpnLPOlM/downloaded_packages
> Warning messages:
> 1: installation of package 'gstat' had non-zero exit status in: 
> install.packages("gstat")
> 2: cannot create HTML package index in: tools:::unix.packages.html(.Library)
> but when I first do install.packges("sp"), followed by ("gstat"), there
> are no problems. I guess that my R version doesn't check for the
> dependencies first, or guesses (wrong) that sp is fine: the dependence
> on sp is rather complicated: if R >= 2.4, require sp >= 0.9, else sp >=
> 0.8. This is hard to express in DESCRIPTION.

Yes, the good things in 2.4.0 (much faster loading time of packages, 
faster performance with spatial classes in sp, etc.) come at a price. My 
experience is that (some) packages depending on sp, or indirectly by 
depending on packages that depend on sp, need to be install.packages() 
from scratch (my experience so far on Linux). I think in addition that the 
failed package load when a pre-2.4.0 package's namespace doesn't load, 
followed by an install.packages() of the offending package, doesn't clear 
the failed load, so without quitting R and restarting, it is difficult to 

I think that the problem is that package R-code binary images in packages
depending even indirectly on packages impacted by the changes in
representation of new-style classes made in the 2.4.0 methods package
still "remember" the previous representation, leading to fresh
installation being required. The package dependency graph in R is now
getting unwieldy, but progress is being made - the present troubles are
just a symptom of moving from a less satisfactory solution to a more
satisfactory one (I hope!).

Bottom line: on the 2.3.1/2.4.0 boundary:

1) save all spatial objects using sp classes externally (not in .RData!), 
for instance as shapefiles or geotiff, before upgrading, and import them 
again after upgrading and resolving 2).

2) trial and error library() of the packages you use, using 
install.packages() and quitting and restarting R until the hiccups go 
away. Remember that sp for 2.4.0 is >= 0.9-1. Takes at most 15 minutes.


> Bests,
> --
> Edzer

Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no

More information about the R-sig-Geo mailing list