Bug 14385 - library.dynam.unload() fails on relative lib.loc path
library.dynam.unload() fails on relative lib.loc path
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Low-level
R 2.11.1 patched
ix86 (32-bit) Windows 32-bit
: P5 normal
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-09-22 16:34 UTC by Duncan Murdoch
Modified: 2010-10-01 20:30 UTC (History)
0 users

See Also:


Attachments
Sample package for demo; depends on Rcpp (8.80 KB, application/x-tar)
2010-09-22 16:34 UTC, Duncan Murdoch
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Duncan Murdoch 2010-09-22 16:34:40 UTC
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 . )
* R
> > library(foo, lib.loc="local/")
> >.dynLibs()
# there you should be able to see the foo.so lib, in my case
/x05/people/m160508/workspace/foo/local/foo/libs/foo.so

> > 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".

#This fails:
> >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")
Karl

On Tue, Sep 21, 2010 at 5:33 PM, Duncan Murdoch <murdoch.duncan@gmail.com>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
> >
Comment 1 Brian Ripley 2010-10-01 20:30:53 UTC
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.