Namespace Reloading Limits in R Packages
0 reputation · 04 Aug 2026, 17:24 UTC
Reloading Packages During a Session
In a small R application that must remain responsive, an administrator may wish to upgrade a dependency without restarting the R process. The goal is to replace a package’s code while the session continues, preserving the global environment and other loaded packages.
R’s namespace system is documented to load packages into isolated environments and to add them to the search path via library(). Reloading a package with library() or detach() is side‑effecting: it can mask objects of the same name and may not merge the old and new namespaces. Because the interpreter is single‑threaded for most operations, there is no built‑in hot‑swap mechanism that guarantees zero‑downtime reloading.
Given this behavior, the following points remain unclear for a zero‑downtime migration strategy:
- When a package is reloaded, does R replace the entire namespace or merge it with the existing one?
- How does R resolve symbol masking between the old and new versions of a package when multiple packages export the same name?
- Can internal objects of a package be safely reloaded if other loaded packages depend on them, or does that risk breaking those dependencies?