-
Notifications
You must be signed in to change notification settings - Fork 301
Description
Overview
Vendoring rlang's standalone "types-check" helpers with usethis::use_standalone() requires import(rlang) in NAMESPACE due to C symbol registration.
Example
When using usethis::use_standalone("r-lib/rlang", file = "types-check") to vendor rlang's argument/type checking helpers (e.g., check_bool()), the resulting functions fail at runtime unless the host package includes import(rlang) in its NAMESPACE.
Using only importFrom(rlang, check_bool) or related partial imports does not register the required C-level backend symbols (e.g., ffi_standalone_is_bool_*), resulting in errors like:
Error in check_bool(FALSE) : object 'ffi_standalone_is_bool_1.0.7' not foundThis seems to defeat the primary appeal of the "standalone" vendoring model for packages that want to minimize imports and namespace pollution.
Steps to Reproduce
- In a package, run:
usethis::use_standalone("r-lib/rlang", file = "types-check")- Call
check_bool(FALSE)in your package:
pkgload::load_all()
check_bool(FALSE)Observe the error about the missing C symbol unless you add import(rlang) as a full import.
Note
The error will occur regardless if the underlying function being tested, i.e. check_bool is imported in NAMESPACE or not. Only full import(rlang) works.
Expected
Vendored "standalone" helpers—especially those intended for minimal-dependency usage—should not require a full import(rlang). Or, if they now require C symbols, documentation should clearly reflect this required import, so package authors understand that vendoring is only an API stability convenience, not a dependency reducer for these functions.
Actual
Full import is required for runtime C symbol registration. Partial imports or vendoring alone are insufficient due to the C backend of the helpers. This leads to confusing "object ... not found" errors for consumers following minimal dependency best practices.
Questions & Suggestions
Could usethis (or rlang standalone docs) clarify that full import(rlang) is required for all C-backed standalone helpers?
Is there a possibility for the vendored R wrappers to check import status at runtime and error clearly, or for usethis to warn during vendoring?
Should this limitation/warning be more prominently featured in the templates or documentation?