[Rd] unloadNamespace inside .Last.lib

From: Benjamin Tyner <btyner_at_gmail.com>
Date: Thu 28 Sep 2006 - 13:15:46 GMT


In my package's zzz.R, I put

.Last.lib <- function(libpath) {

    unloadNamespace("mypackage")
}

and I exported .Last.lib in NAMESPACE, with the intent that detaching the package would also cause the name space to be unloaded. However, the result of detach("package:mypackage") is then

Error: evaluation nested too deeply: infinite recursion / options(expressions=)?<environment: namespace:mypackage>
<environment: namespace:mypackage>

Error in library.dynam.unload("mypackage", libpath) :

        shared library 'mypackage' was not loaded Error in as.character(<environment>) : cannot coerce to vector Error in unregisterNamespace(nsname) : name space not registered
<environment: namespace:mypackage>

Error in library.dynam.unload("mypackage", libpath) :

        shared library 'mypackage' was not loaded Error in as.character(<environment>) : cannot coerce to vector Error in unregisterNamespace(nsname) : name space not registered
<environment: namespace:mypackage>

Error in library.dynam.unload("mypackage", libpath) :

        shared library 'mypackage' was not loaded Error in as.character(<environment>) : cannot coerce to vector Error in unregisterNamespace(nsname) : name space not registered
<environment: namespace:mypackage>

Error in library.dynam.unload("mypackage", libpath) :

        shared library 'mypackage' was not loaded Error in as.character(<environment>) : cannot coerce to vector Error in unregisterNamespace(nsname) : name space not registered
<environment: namespace:mypackage>

Error in library.dynam.unload("mypackage", libpath) :

        shared library 'mypackage' was not loaded Error in as.character(<environment>) : cannot coerce to vector Error in unregisterNamespace(nsname) : name space not registered
<environment: namespace:mypackage>

Error in library.dynam.unload("mypackage", libpath) :

        shared library 'mypackage' was not loaded Error in as.character(<environment>) : cannot coerce to vector Error in unregisterNamespace(nsname) : name space not registered
<environment: namespace:mypackage>

Error in library.dynam.unload("mypackage", libpath) :

        shared library 'mypackage' was not loaded Error in as.character(<environment>) : cannot coerce to vector Error in unregisterNamespace(nsname) : name space not registered

Error in detach(pos) : detaching "package:base" is not allowed
Error in detach(pos) : detaching "package:base" is not allowed
Error in detach(pos) : detaching "package:base" is not allowed


With a hundred more or so of the last error. What is the correct way (if any) to unload a name space using detach() alone ?

Thanks,
Ben



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu Sep 28 23:17:15 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 28 Sep 2006 - 14:30:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.