load_all() loads a package. It roughly simulates what happenswhen a package is installed and loaded withlibrary(), withouthaving to first install the package. It:
Loads all data files in
data/. Seeload_data()for moredetails.Sources all R files in the R directory, storing results inenvironment that behaves like a regular package namespace. See
load_code()for more details.Adds a shim from
system.file()toshim_system.file()inthe imports environment of the package. This ensures thatsystem.file()works with both development and installed packages despite their differingdirectory structures.Adds shims from
help()and?toshim_help()andshim_question()to make it easier to preview development documentation.Compiles any C, C++, or Fortran code in the
src/directory andconnects the generated DLL into R. Seepkgbuild::compile_dll()for more details.Loads any compiled translations in
inst/po.Runs
.onAttach(),.onLoad()and.onUnload()functions atthe correct times.If you usetestthat, will load all test helpers so you canaccess them interactively. devtools sets the
DEVTOOLS_LOADenvironment variable to the package name to let you check whether thehelpers are run during package loading.
is_loading() returnsTRUE when it is called whileload_all()is running. This may be useful e.g. in.onLoad hooks.A package loaded withload_all() can be identified withis_dev_package().
Usage
load_all( path=".", reset=TRUE, recompile=FALSE, export_all=TRUE, helpers=TRUE, quiet=FALSE,...)Arguments
- path
Path to a package, or within a package.
- reset
This is no longer supportedbecause preserving the namespace requires unlocking its environment, whichis no longer possible in recent versions of R.
- recompile
DEPRECATED. force a recompile of DLL from source code, ifpresent. This is equivalent to running
pkgbuild::clean_dll()beforeload_all()- export_all
If
TRUE(the default), export all objects.IfFALSE, export only the objects that are listed as exportsin the NAMESPACE file.- helpers
if
TRUEloadstestthat test helpers.- quiet
if
TRUEsuppresses output from this function.- ...
Additional arguments passed to
pkgload::load_all().
Differences to regular loading
load_all() tries its best to reproduce the behaviour ofloadNamespace() andlibrary(). However it deviates from normalpackage loading in several ways.
load_all()doesn't install the package to a library, sosystem.file()doesn't work. pkgload fixes this for the package itself installing a shim,shim_system.file(). However, this shim is not visible to third partypackages, so they will fail if they attempt to find files within yourpackage. One potential workaround is to usefs::path_package()instead ofsystem.file(), since that understands the mechanisms thatdevtools uses to load packages.load_all()loads all packages referenced inImportsat load time,butloadNamespace()andlibrary()only load package dependencies asthey are needed.load_all()copies all objects (not just the ones listed as exports)into the package environment. This is useful during development becauseit makes internal objects easy to access. To export only the objectslisted as exports, useexport_all = FALSE. This more closely simulatesbehavior when loading an installed package withlibrary(), and canbe useful for checking for missing exports.
Controlling the debug compiler flags
load_all() delegates topkgbuild::compile_dll() to perform the actualcompilation, during which by default some debug compiler flags areappended. If you would like to produce an optimized build instead, you canopt out by either usingdebug = FALSE, setting thepkg.build_extra_flagsoption toFALSE, or setting thePKG_BUILD_EXTRA_FLAGS environment variabletoFALSE. For further details see the Details section inpkgbuild::compile_dll().
