Skip to content

Confusion over "standalone" use cases for C symbol dependent functions (i.e. rlang "types-check") #2155

@jimbrig

Description

@jimbrig

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 found

This seems to defeat the primary appeal of the "standalone" vendoring model for packages that want to minimize imports and namespace pollution.

Steps to Reproduce

  1. In a package, run:
usethis::use_standalone("r-lib/rlang", file = "types-check")
  1. 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?

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