Created attachment 1128 [details]
Sample package for demo; depends on Rcpp
This was posted by Karl Forner and I can reproduce it in R-patched:
Thanks Duncan for your suggestion.
I could not find any package using dynamic library, namespaces and not the
useDynLib pragma so
I created a minimalistic package to demonstrate the problem.
Please find attached a very small package foo (8.8k)
Steps to reproduce the problem:
* unarchive it ( tar zxvf foo_0.1.tar.gz )
* cd foo
* install it locally ( mkdir local; R CMD INSTALL -l local . )
> > library(foo, lib.loc="local/")
# there you should be able to see the foo.so lib, in my case
> > unloadNamespace("foo")
.onUnload, libpath= local/fooWarning message:
.onUnload failed in unloadNamespace() for 'foo', details:
call: library.dynam.unload("foo", libpath)
error: shared library 'foo' was not loaded
#The libpath that the .onUnload() gets is "local/foo".
> >library.dynam.unload("foo", "local/foo")
Error in library.dynam.unload("foo", "local/foo") :
shared library 'foo' was not loaded
# but if you use the absolute path it works:
> >library.dynam.unload("foo", "/x05/people/m160508/workspace/foo/local/foo")
On Tue, Sep 21, 2010 at 5:33 PM, Duncan Murdoch <firstname.lastname@example.org>wrote:
> > On 21/09/2010 10:38 AM, Karl Forner wrote:
>> >> Hello,
>> >> I got no reply on this issue.
>> >> It is not critical and I could think of work-around, but it really looks
>> >> like a bug to me.
>> >> Should I file a bug-report instead of posting in this list ?
> > I'd probably post instructions for a reproducible example first. Pick some
> > CRAN package, tell us what to do with it to trigger the error, and then we
> > can see if it's something special about your package or Roxygen or a general
> > problem.
> > Duncan Murdoch
I think this is rather a bug in loadNamespace. Suppose setwd() had been called after the package was loaded and befoe unloadNamespace() was called: the relative path stored in the name space registry would be invalid.
In any case, changed for 2.12.0.