Skip to content

Can't move generics to another package #729

Closed

Description

@hadley

Found while verifying the evolution vignette scenarios (#143), in the gen-move-package and gen-rename scenarios of tools/evolution/.

When pkgB has a deferred method registration whose generic no longer exists as a direct binding in the recorded package, loading pkgB fails hard:

Error: package or namespace load failed for 'evoB':
 .onLoad failed in loadNamespace() for 'evoB', details:
  call: get(generic$name, envir = ns, inherits = FALSE)
  error: object 'gen' not found

Two problems in resolve_generic_opt():

  1. It errors instead of returning NULL. resolve_generic() is written to warn "[S7] Failed to find generic %s() in package %s" when resolution fails, but resolve_generic_opt() uses get() rather than get0(), so a missing generic throws from inside the load hook and takes down library(pkgB) entirely. An installed pkgB should degrade to a warning when pkgA renames a generic, not become unloadable.

  2. It can't see re-exports. get(..., envir = ns, inherits = FALSE) misses bindings that pkgA re-exports from another package (they live in the imports environment, not the namespace proper). So when pkgA moves a generic to pkgAcore and re-exports it every already-installed downstream package fails to load. Resolving via getExportedValue() (falling back to the namespace itself for own, unexported generics) would make the move seamless for stale installs too.

Activity

  1. changed the title [-]resolve_generic_opt() breaks package load for stale downstream installs; can't resolve re-exported generics[/-] [+]Can't move generics to another package[/+] on Jul 27, 2026
  2. added a commit that references this issue on Jul 31, 2026
  3. added a commit that references this issue on Oct 2, 2026
    2ef8e3e
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