[R] installing package with version number using namespaces & dynamic library
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Aug 4 14:40:20 CEST 2004
On Wed, 4 Aug 2004, Matthias Burger wrote:
> I wonder whether a package with namespace & dynamic library can be installed
> with the version number attached, ie. with the argument --with-package-versions.
> Is this currently possible?
I've just successfully done this with package tree, so yes.
gannet% R CMD INSTALL --with-package-versions tree_1.0-16.tar.gz
gannet% R
...
> library(tree)
> library(tree, version="1.0-16")
both work.
The crucial piece of code in namespace loading is
# load any dynamic libraries
for (lib in nsInfo$dynlibs)
library.dynam(lib, package, package.lib)
which is *not* the call to library.dynam you quote. I think you have a
call to library.dynam in your .onLoad, rather than/as well as using the
useDynLib directive. .onLoad *is* run with the versioned package name as
its `pkgname' argument, and we should document that.
> Using R 1.9.1 on Debian 3.0 I encounter a problem when trying to load a package
> installed with
>
> R91 CMD INSTALL --with-package-versions -l /mnt/local/R/R-1.9.x-libs-EpiR RIO
>
> in R started with
> R91 --vanilla
>
> > .libPaths()
> [1] "/mnt/local/R/R-1.9.x-libs" "/mnt/local/R/R-1.9.x-libs-BioC"
> [3] "/mnt/local/R/R-1.9.x-libs-EpiR" "/mnt/local/R/R-1.9.1/lib/R/library"
>
> either
> > library("RIO")
> Error in library.dynam(pkg, pkg, lib) : shared library 'RIO_1.4.0' not found
> Error: .onLoad failed in loadNamespace
> Error in library("RIO") : package/namespace load failed
> or
> > library("RIO_1.4.0")
> Error in library.dynam(pkg, pkg, lib) : shared library 'RIO_1.4.0' not found
> Error: .onLoad failed in loadNamespace
> Error in library("RIO_1.4.0") : package/namespace load failed
>
> fail.
>
> Without the '--with-package-versions' option the installed package loads without
> problem with the call
> library("RIO")
>
>
> file Namesapce defines (amoung other directives):
>
> useDynLib(RIO)
>
> I also tryed
> useDynLib("RIO_1.4.0")
> to no avail. But RIO/libs contains the file RIO.so anyway.
[As it should.]
> I checked in 'Writing R Extensions" section 'Package name spaces' but did not
> find an answer.
--
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-help
mailing list