Skip to content

load_code unintentionally public? #335

Description

@pearsonca

I'm attempting to use pkgload in a boot-strappy context with data-raw - basically, I want to use part of the R API while building the data.

I may be misreading, but load_all doesn't seem to support a code-only version. Hence, I went to load_code, which suggests it loads only the code.

However, when I attempt to use load_code() directly:

Error in source_many(paths, encoding, env) : 
  is.environment(envir) is not TRUE
Error in `unload()`:
! Package testtesttest not found in loaded packages or namespaces.
Run `rlang::last_trace()` to see where the error occurred.

(here testtesttest is the pure skeleton package from Rstudio -> Create Project -> Create R package)

The culprit seems to be in ns_env - requires that a namespace already be loaded.

So a few thoughts:

  • is load_code not intended to be public API pkgload?
  • if load_code is supposed to be public API, clearly I'm using it wrong - is there a way to clear up how to use it properly in the documentation?
  • is there another "preferred" approach to acheive what I'm trying to do specifically (load code only as-if packaged in the namespace)?

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