load_all {pkgload}R Documentation

Load complete package

Description

load_all() loads a package. It roughly simulates what happens when a package is installed and loaded with library(), without having to first install the package. It:

is_loading() returns TRUE when it is called while load_all() is running. This may be useful e.g. in .onLoad hooks. A package loaded with load_all() can be identified with with is_dev_package().

Usage

load_all(
  path = ".",
  reset = TRUE,
  compile = NA,
  attach = TRUE,
  export_all = TRUE,
  export_imports = export_all,
  helpers = export_all,
  attach_testthat = uses_testthat(path),
  quiet = NULL,
  recompile = FALSE,
  warn_conflicts = TRUE
)

is_loading(pkg = NULL)

Arguments

path

Path to a package, or within a package.

reset

[Deprecated] This is no longer supported because preserving the namespace requires unlocking its environment, which is no longer possible in recent versions of R.

compile

If TRUE always recompiles the package; if NA recompiles if needed (as determined by pkgbuild::needs_compile()); if FALSE, never recompiles.

attach

Whether to attach a package environment to the search path. If FALSE load_all() behaves like loadNamespace(). If TRUE (the default), it behaves like library(). If FALSE, the export_all, export_imports, and helpers arguments have no effect.

export_all

If TRUE (the default), export all objects. If FALSE, export only the objects that are listed as exports in the NAMESPACE file.

export_imports

If TRUE (the default), export all objects that are imported by the package. If FALSE export only objects defined in the package.

helpers

if TRUE loads testthat test helpers.

attach_testthat

If TRUE, attach testthat to the search path, which more closely mimics the environment within test files.

quiet

if TRUE suppresses output from this function.

recompile

DEPRECATED. force a recompile of DLL from source code, if present. This is equivalent to running pkgbuild::clean_dll() before load_all()

warn_conflicts

If TRUE, issues a warning if a function in the global environment masks a function in the package. This can happen when you accidentally source a .R file, rather than using load_all(), or if you define a function directly in the R console. This is frustrating to debug, as it feels like the changes you make to the package source aren't having the expected effect.

pkg

If supplied, is_loading() only returns TRUE if the package being loaded is pkg.

Differences to regular loading

load_all() tries its best to reproduce the behaviour of loadNamespace() and library(). However it deviates from normal package loading in several ways.

Examples

## Not run: 
# Load the package in the current directory
load_all("./")

# Running again loads changed files
load_all("./")

# With export_all=FALSE, only objects listed as exports in NAMESPACE
# are exported
load_all("./", export_all = FALSE)

## End(Not run)

[Package pkgload version 1.4.0 Index]