pkgload icon indicating copy to clipboard operation
pkgload copied to clipboard

`.onUnload()` is no longer called

Open hadley opened this issue 11 months ago • 2 comments

Probably because of the changes in 2d28e266bf111b3e49a5e1a473b053c7104d5459 where we no longer call unloadNamespace(). So now we should call .onUnload() if present, and similarly handle the onUnload hook.

hadley avatar Jul 25 '23 20:07 hadley

hmm, one problem I can see with this is that we try to preserve stale namespaces in a working state since it's so easy to run into dangling references, for example via an imports env populated before a load_all() call.

So it depends on what conventions should apply to the unload hook. Is it UB to call into a namespace that has run this hook, or should the package gracefully handle this situation?

lionel- avatar Sep 20 '23 06:09 lionel-

Not calling .onUnload() was intentional according to https://github.com/r-lib/pkgload/issues/148#issuecomment-790910702

DavisVaughan avatar Feb 27 '24 16:02 DavisVaughan