Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function ".onUnload" is not executed when "load_all" is called #148

Closed
nextpagesoft opened this issue Mar 1, 2021 · 1 comment
Closed

Comments

@nextpagesoft
Copy link

Hi, version 1.2 does not execute .onUnload function if defined within an R package. I'm not sure this an intended behaviour as this means that any clean up code a package maintainer defined is not executed. For instance shiny::removeInputHandler is commonly placed in .onUnload to clean up after shiny::registerInputHandler in .onLoad.

Steps to reproduce:

  1. Create a bare minimal R package
  2. Define .onLoad and .onUload as:
.onLoad <- function(libname, pkgname) {
  print('.onLoad')

  invisible(NULL)
}

.onUnload <- function(libname, pkgname) {
  print('.onUnload')

  invisible(NULL)
}
  1. Execute pkgload::load_all("."). Only ".onLoad" is printed regardless of value provided for argument reset.
@nextpagesoft nextpagesoft changed the title Function ".onUnload" is not executed with "load_all" is called Function ".onUnload" is not executed when "load_all" is called Mar 1, 2021
@jimhester
Copy link
Member

It does if you explicitly call unload(), however pkgload::load_all() no longer fully unloads the namespace as of #133, as doing so can cause crashes for packages using compiled code.

So this is working as designed. If your usage is assuming the uload is called you will need to explicitly call unload() before running load_all().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants