Skip to content

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

Closed

Description

@nextpagesoft

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.

Activity

  1. changed the title [-]Function ".onUnload" is not executed with "load_all" is called[/-] [+]Function ".onUnload" is not executed when "load_all" is called[/+] on Mar 1, 2021
  2. jimhester commented on Mar 4, 2021

    @jimhester
    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().

  3. added a commit that references this issue on Mar 13, 2025
    cdb3b89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions