| Title: | Tools to Make Developing R Packages Easier |
| Version: | 2.5.0 |
| Description: | Collection of package development tools. |
| License: | MIT + file LICENSE |
| URL: | https://devtools.r-lib.org/, https://github.com/r-lib/devtools |
| BugReports: | https://github.com/r-lib/devtools/issues |
| Depends: | R (≥ 4.1), usethis (≥ 3.2.1) |
| Imports: | cli (≥ 3.6.5), desc (≥ 1.4.3), ellipsis (≥ 0.3.2), fs (≥ 1.6.7), lifecycle (≥ 1.0.5), memoise (≥ 2.0.1), miniUI (≥ 0.1.2), pak (≥ 0.9.2), pkgbuild (≥ 1.4.8), pkgdown (≥ 2.2.0), pkgload (≥ 1.5.0), profvis (≥ 0.4.0), rcmdcheck (≥ 1.4.0), rlang (≥ 1.1.7), roxygen2 (≥ 7.3.3), rversions (≥ 3.0.0), sessioninfo (≥ 1.2.3), testthat (≥ 3.3.2), urlchecker (≥ 1.0.1), withr (≥ 3.0.2) |
| Suggests: | BiocManager (≥ 1.30.18), callr (≥ 3.7.1), covr (≥ 3.5.1), curl (≥ 4.3.2), digest (≥ 0.6.29), DT (≥ 0.23), foghorn (≥ 1.4.2), gh (≥ 1.3.0), httr2 (≥ 1.0.0), knitr (≥ 1.39), lintr (≥ 3.0.0), quarto (≥ 1.5.1), remotes (≥ 2.5.0), rmarkdown (≥ 2.14), rstudioapi (≥ 0.13), spelling (≥ 2.2), xml2 |
| VignetteBuilder: | knitr, quarto |
| Config/Needs/website: | tidyverse/tidytemplate |
| Config/testthat/edition: | 3 |
| Config/testthat/parallel: | true |
| Encoding: | UTF-8 |
| Language: | en-US |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | no |
| Packaged: | 2026-03-13 23:00:32 UTC; jenny |
| Author: | Hadley Wickham [aut],
Jim Hester [aut],
Winston Chang [aut],
Jennifer Bryan |
| Maintainer: | Jennifer Bryan <jenny@posit.co> |
| Repository: | CRAN |
| Date/Publication: | 2026-03-14 16:40:28 UTC |
devtools: Tools to Make Developing R Packages Easier
Description
Collection of package development tools.
Package options
Devtools uses the following options() to configure behaviour:
-
devtools.install.args: a string giving extra arguments passed toR CMD installbyinstall(). -
devtools.path: Deprecated. Path used by the now-deprecateddev_mode()function.
Author(s)
Maintainer: Jennifer Bryan jenny@posit.co (ORCID)
Authors:
Hadley Wickham
Jim Hester
Winston Chang
Other contributors:
Posit Software, PBC (ROR) [copyright holder, funder]
See Also
Useful links:
Report bugs at https://github.com/r-lib/devtools/issues
Coerce input to a package
Description
Possible specifications of package:
path
package object
Usage
as.package(x = NULL, create = deprecated())
Arguments
x |
object to coerce to a package |
create |
Open bash shell in package directory
Description
bash() is deprecated because we no longer use or recommend this workflow.
Open bash shell in package directory
Usage
bash(pkg = ".")
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
Build package
Description
Building converts a package source directory into a single bundled file.
If binary = FALSE this creates a tar.gz package that can
be installed on any platform, provided they have a full development
environment (although packages without source code can typically be
installed out of the box). If binary = TRUE, the package will have
a platform specific extension (e.g. .zip for windows), and will
only be installable on the current platform, but no development
environment is needed.
Usage
build(
pkg = ".",
path = NULL,
binary = FALSE,
vignettes = TRUE,
manual = FALSE,
args = NULL,
quiet = FALSE,
...
)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
path |
Path in which to produce package. If |
binary |
Produce a binary ( |
vignettes, manual |
For source packages: if |
args |
An optional character vector of additional command
line arguments to be passed to |
quiet |
if |
... |
Additional arguments passed to pkgbuild::build. |
Details
Configuration
DESCRIPTION entries
-
Config/build/clean-inst-doccan be set toFALSEto avoid cleaning upinst/docwhen building a source package. Set it toTRUEto force a cleanup. See theclean_docargument. -
Config/build/copy-methodcan be used to avoid copying large directories inR CMD build. It works by copying (or linking) the files of the package to a temporary directory, leaving out the (possibly large) files that are not part of the package. Possible values:-
none: pkgbuild does not copy the package tree. This is the default. -
copy: the package files are copied to a temporary directory before R CMD build. -
link: the package files are symbolic linked to a temporary directory beforeR CMD build. Windows does not have symbolic links, so on Windows this is equivalent tocopy.
You can also use the
pkg.build_copy_methodoption or thePKG_BUILD_COPY_METHODenvironment variable to set the copy method. The option is consulted first, then theDESCRIPTIONentry, then the environment variable. -
-
Config/build/extra-sourcescan be used to define extra source files for pkgbuild to decide whether a package DLL needs to be recompiled inneeds_compile(). The syntax is a comma separated list of file names, or globs. (Seeutils::glob2rx().) E.g.src/rust/src/*.rsorconfigure*. -
Config/build/bootstrapcan be set toTRUEto runRscript bootstrap.Rin the source directory prior to running subsequent build steps. -
Config/build/never-cleancan be set toTRUEto never add--precleantoR CMD INSTALL, e.g., when header files have changed. This helps avoiding rebuilds that can take long for very large C/C++ codebases and can lead to build failures if object files are out of sync with header files. Control the dependencies between object files and header files by addinginclude file.dtoMakevarsfor eachfile.corfile.cppsource file.
Options
-
pkg.build_copy_method: use this option to avoid copying large directories when building a package. See possible values above, at theConfig/build/copy-methodDESCRIPTIONentry. -
pkg.build_stop_for_warnings: if it is set toTRUE, then pkgbuild will stop forR CMD builderrors. It takes precedence over thePKG_BUILD_STOP_FOR_WARNINGSenvironment variable.
Environment variables
-
PKG_BUILD_COLOR_DIAGNOSTICS: set it tofalseto opt out of colored compiler diagnostics. Set it totrueto force colored compiler diagnostics. -
PKG_BUILD_COPY_METHOD: use this environment variable to avoid copying large directories when building a package. See possible values above, at theConfig/build/copy-methodDESCRIPTIONentry.
will stop for R CMD build errors. The pkg.build_stop_for_warnings
option takes precedence over this environment variable.
Value
a string giving the location (including file name) of the built package
Note
The default manual = FALSE is not suitable for a CRAN
submission, which may require manual = TRUE. Even better, use
submit_cran() or release().
Create package pdf manual
Description
Create package pdf manual
Usage
build_manual(pkg = ".", path = NULL)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
path |
path in which to produce package manual.
If |
See Also
Build README
Description
Renders an executable README, i.e. README.qmd or README.Rmd, to
README.md. Specifically, build_readme():
Installs a copy of the package's current source to a temporary library
Renders the README in a clean R session
Usage
build_readme(path = ".", quiet = TRUE, ...)
Arguments
path |
Path to the top-level directory of the source package. |
quiet |
If |
... |
Additional arguments passed to |
Build Rmarkdown files
Description
build_rmd() is deprecated, as it is a low-level helper for internal use. To
render your package's README.qmd or README.Rmd, use build_readme(). To
preview a vignette or article, use functions like pkgdown::build_site() or
pkgdown::build_article().
Usage
build_rmd(files, path = ".", output_options = list(), ..., quiet = TRUE)
Arguments
files |
The Rmarkdown files to be rendered. |
path |
path to the package to build the readme. |
output_options |
List of output options that can override the options
specified in metadata (e.g. could be used to force |
... |
additional arguments passed to |
quiet |
If |
Run pkgdown::build_site()
Description
This is a thin wrapper around pkgdown::build_site(), used for generating
static HTML documentation. Learn more at https://pkgdown.r-lib.org.
Usage
build_site(path = ".", ...)
Arguments
path |
Path to the package to build the static HTML. |
... |
Additional arguments passed to |
Build package vignettes
Description
build_vignettes() is deprecated because we no longer recommend that you
build vignettes in this way, because it leaves build artifacts in your
development directory. Instead, use pkgdown::build_article() to
render articles locally for preview and polishing.
Usage
build_vignettes(
pkg = ".",
dependencies = "VignetteBuilder",
clean = TRUE,
upgrade = "never",
quiet = FALSE,
install = TRUE,
keep_md = TRUE
)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
dependencies |
Which dependencies do you want to check? Can be a character vector (selecting from "Depends", "Imports", "LinkingTo", "Suggests", or "Enhances"), or a logical vector.
The value "soft" means the same as You can also specify dependencies from one or more additional fields, common ones include:
|
clean |
Remove all files generated by the build, even if there were copies there before. |
upgrade |
Should package dependencies be upgraded? One of "default", "ask", "always", or "never". "default"
respects the value of the |
quiet |
If |
install |
If |
keep_md |
If |
Build and check a package
Description
check() automatically builds and checks a source package, using all known
best practices. check_built() checks an already-built package.
Passing R CMD check is essential if you want to submit your package to
CRAN: you must not have any ERRORs or WARNINGs, and you want to ensure that
there are as few NOTEs as possible. If you are not submitting to CRAN, at
least ensure that there are no ERRORs or WARNINGs: these typically represent
serious problems.
check() automatically builds a package before calling check_built(), as
this is the recommended way to check packages. Note that this process runs
in an independent R session, so nothing in your current workspace will affect
the process. Under-the-hood, check() and check_built() rely on
pkgbuild::build() and rcmdcheck::rcmdcheck().
Usage
check(
pkg = ".",
document = NULL,
build_args = NULL,
...,
manual = FALSE,
cran = TRUE,
remote = FALSE,
incoming = remote,
force_suggests = FALSE,
run_dont_test = FALSE,
args = "--timings",
env_vars = c(NOT_CRAN = "true"),
quiet = FALSE,
check_dir = NULL,
cleanup = deprecated(),
vignettes = TRUE,
error_on = c("never", "error", "warning", "note")
)
check_built(
path = NULL,
cran = TRUE,
remote = FALSE,
incoming = remote,
force_suggests = FALSE,
run_dont_test = FALSE,
manual = FALSE,
args = "--timings",
env_vars = NULL,
check_dir = tempdir(),
quiet = FALSE,
error_on = c("never", "error", "warning", "note")
)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
document |
By default ( |
build_args |
Additional arguments passed to |
... |
Additional arguments passed on to |
manual |
If |
cran |
if |
remote |
Sets |
incoming |
Sets |
force_suggests |
Sets |
run_dont_test |
Sets |
args |
Character vector of arguments to pass to |
env_vars |
Environment variables set during |
quiet |
if |
check_dir |
Path to a directory where the check is performed.
If this is not |
cleanup |
|
vignettes |
If |
error_on |
Whether to throw an error on
|
path |
Path to built package. |
Value
An object containing errors, warnings, notes, and more.
Environment variables
Devtools does its best to set up an environment that combines best practices with how check works on CRAN. This includes:
The standard environment variables set by devtools:
r_env_vars(). Of particular note for package tests is theNOT_CRANenv var, which lets you know that your tests are running somewhere other than CRAN, and hence can take a reasonable amount of time.Debugging flags for the compiler, set by
compiler_flags(FALSE).If
aspellis found,_R_CHECK_CRAN_INCOMING_USE_ASPELL_is set toTRUE. If no spell checker is installed, a warning is issued.Environment variables, controlled by arguments
incoming,remoteandforce_suggests.
See Also
release() if you want to send the checked package to
CRAN.
Check for missing documentation fields
Description
Checks all Rd files in man/ and looks for any that have a \usage section
(i.e. a function) but that don't have \value and \examples sections.
These missing fields are flagged by CRAN on initial submission.
Usage
check_doc_fields(pkg = ".", fields = c("value", "examples"))
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
fields |
A character vector of Rd field names to check for. |
Value
A named list of character vectors, one for each field, containing the names of Rd files missing that field. Returned invisibly.
Examples
## Not run:
check_doc_fields(".")
## End(Not run)
Check a package on macOS
Description
Check on either the released or development versions of R, using https://mac.r-project.org/macbuilder/submit.html.
Usage
check_mac_release(
pkg = ".",
dep_pkgs = character(),
args = NULL,
manual = TRUE,
quiet = FALSE,
...
)
check_mac_devel(
pkg = ".",
dep_pkgs = character(),
args = NULL,
manual = TRUE,
quiet = FALSE,
...
)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
dep_pkgs |
Additional custom dependencies to install prior to checking the package. |
args |
An optional character vector of additional command
line arguments to be passed to |
manual |
Should the manual be built? |
quiet |
If |
... |
Additional arguments passed to |
Value
The url with the check results (invisibly)
See Also
Other build functions:
check_win()
Check documentation, as R CMD check does
Description
This function attempts to run the documentation related checks in the
same way that R CMD check does. Unfortunately it can't run them
all because some tests require the package to be loaded, and the way
they attempt to load the code conflicts with how devtools does it.
Usage
check_man(pkg = ".")
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
Value
Nothing. This function is called purely for it's side effects: if no errors there will be no output.
Examples
## Not run:
check_man("mypkg")
## End(Not run)
Run CRAN checks for package on R-hub
Description
This function is deprecated since the underlying function
rhub::check_for_cran() is now deprecated and defunct. See rhub::rhubv2
learn about the new check system, R-hub v2.
Usage
check_rhub(
pkg = ".",
platforms = NULL,
email = NULL,
interactive = TRUE,
build_args = NULL,
...
)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
platforms |
R-hub platforms to run the check on. |
email |
email address to notify. |
interactive |
whether to show the status of the build. |
build_args |
Arguments passed to |
... |
extra arguments, passed to |
Value
a rhub_check object.
Check a package on Windows
Description
This function first bundles a source package, then uploads it to
https://win-builder.r-project.org/. Once the service has built and checked
the package, an email is sent to address of the maintainer listed in
DESCRIPTION. This usually takes around 30 minutes. The email contains a
link to a directory with the package binary and check logs, which will be
deleted after a couple of days.
Usage
check_win_devel(
pkg = ".",
args = NULL,
manual = TRUE,
email = NULL,
quiet = FALSE,
webform = FALSE,
...
)
check_win_release(
pkg = ".",
args = NULL,
manual = TRUE,
email = NULL,
quiet = FALSE,
webform = FALSE,
...
)
check_win_oldrelease(
pkg = ".",
args = NULL,
manual = TRUE,
email = NULL,
quiet = FALSE,
webform = FALSE,
...
)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
args |
An optional character vector of additional command
line arguments to be passed to |
manual |
Should the manual be built? |
email |
An alternative email address to use. If |
quiet |
If |
webform |
If |
... |
Additional arguments passed to |
Functions
-
check_win_devel(): Check package on the development version of R. -
check_win_release(): Check package on the released version of R. -
check_win_oldrelease(): Check package on the previous major release version of R.
See Also
Other build functions:
check_mac_release()
Clean built vignettes
Description
clean_vignettes() is deprecated because build_vignettes() is deprecated.
Usage
clean_vignettes(pkg = ".")
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
Create a package
Description
create() is deprecated. Please use usethis::create_package() directly
instead.
Usage
create(path, ..., open = FALSE)
Arguments
path |
A path. If it exists, it is used. If it does not exist, it is created, provided that the parent path exists. |
... |
Additional arguments passed to |
open |
If
|
Value
The path to the created package, invisibly.
Activate and deactivate development mode
Description
We no longer recommend dev_mode() and it will be removed in a future
release of devtools. Instead, we now rely on load_all() to test drive an
in-development package. If you really like the idea of corralling
experimental packages in a special library, you might enjoy
withr::local_libpaths(). If you are concerned about different projects
interfering with each other through the use of a shared library, consider
using the renv package.
Original description: When activated, dev_mode creates a new library for
storing installed packages. This new library is automatically created when
dev_mode is activated if it does not already exist. This allows you to test
development packages in a sandbox, without interfering with the other
packages you have installed.
Usage
dev_mode(on = NULL, path = getOption("devtools.path"))
Arguments
on |
turn dev mode on ( |
path |
directory to library. |
Examples
## Not run:
dev_mode()
dev_mode()
## End(Not run)
Return a vector of names of packages loaded by devtools
Description
Return a vector of names of packages loaded by devtools
Usage
dev_packages()
Report package development situation
Description
Call this function if things seem weird and you're not sure what's wrong or how to fix it. It reports:
If R is up to date.
If RStudio or Positron is up to date.
If compiler build tools are installed and available for use.
If devtools and its dependencies are up to date.
If the package's dependencies are up to date.
Usage
dev_sitrep(pkg = ".", debug = FALSE)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
debug |
If |
Value
A named list, with S3 class dev_sitrep (for printing purposes).
Examples
## Not run:
dev_sitrep()
## End(Not run)
Defunct functions
Description
These functions are defunct and will be removed in a future version of devtools.
Usage
test_file(file = find_active_file(), ...)
test_coverage_file(file = find_active_file(), ...)
Use roxygen to document a package
Description
This function is a wrapper for the roxygen2::roxygenize()
function from the roxygen2 package. See the documentation and vignettes of
that package to learn how to use roxygen.
Usage
document(pkg = ".", roclets = NULL, quiet = FALSE)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
roclets |
Character vector of roclet names to use with package.
The default, |
quiet |
if |
See Also
roxygen2::roxygenize(),
browseVignettes("roxygen2")
Git checks
Description
This function performs Git checks checks prior to release. It is called
automatically by release().
Usage
git_checks(pkg = ".")
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
Was devtools installed with tests?
Description
Was devtools installed with tests?
Usage
has_tests()
Install a local development package
Description
Uses R CMD INSTALL to install the package, after installing needed
dependencies with pak::local_install_deps().
To install to a non-default library, use withr::with_libpaths().
Usage
install(
pkg = ".",
reload = TRUE,
quick = FALSE,
build = !quick,
args = getOption("devtools.install.args"),
quiet = FALSE,
dependencies = NA,
upgrade = FALSE,
build_vignettes = FALSE,
keep_source = getOption("keep.source.pkgs") || !build,
force = deprecated()
)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
reload |
if |
quick |
if |
build |
If One downside of installing from a built tarball is that the package is
installed from a temporary location. This means that any source references
will point to dangling locations and debuggers won't have direct access to
the source for step-debugging. For development purposes, If |
args |
An optional character vector of additional command line
arguments to be passed to |
quiet |
If |
dependencies |
What kinds of dependencies to install. Most commonly one of the following values:
|
upgrade |
When When |
build_vignettes |
if |
keep_source |
If |
force |
See Also
with_debug() to install packages with debugging flags set.
Other package installation:
uninstall()
Deprecated package installation functions
Description
These functions have been deprecated in favor of pak, as that is what we now recommend for package installation. There are a few functions which have no pak equivalent, where you can instead call the old remotes functions directly.
Migration guide
| devtools function | Replacement |
install_bioc("pkg") | pak::pak("bioc::pkg") |
install_bitbucket("user/repo") | remotes::install_bitbucket("user/repo") |
install_cran("pkg") | pak::pak("pkg") |
install_dev("pkg") | remotes::install_dev("pkg") |
install_git("url") | pak::pak("git::url") |
install_github("user/repo") | pak::pak("user/repo") |
install_gitlab("user/repo") | pak::pak("gitlab::user/repo") |
install_local("path") | pak::pak("local::path") |
install_svn("url") | remotes::install_svn("url") |
install_url("url") | pak::pak("url::url") |
install_version("pkg", "1.0.0") | pak::pak("pkg@1.0.0") |
update_packages("pkg") | pak::pak("pkg") |
dev_package_deps() | pak::local_dev_deps() |
github_pull("123") | remotes::github_pull("123") |
github_release() | remotes::github_release()
|
Usage
install_bioc(...)
install_bitbucket(...)
install_cran(...)
install_dev(...)
install_git(...)
install_github(...)
install_gitlab(...)
install_local(...)
install_svn(...)
install_url(...)
install_version(...)
update_packages(...)
dev_package_deps(...)
github_pull(...)
github_release(...)
Install package dependencies if needed
Description
These functions are deprecated. Better alternatives:
-
pak::local_install_deps()instead ofinstall_deps() -
pak::local_install_dev_deps()instead ofinstall_dev_deps()
Usage
install_deps(
pkg = ".",
dependencies = NA,
repos = getOption("repos"),
type = getOption("pkgType"),
upgrade = c("default", "ask", "always", "never"),
quiet = FALSE,
build = TRUE,
build_opts = c("--no-resave-data", "--no-manual", " --no-build-vignettes"),
...
)
install_dev_deps(
pkg = ".",
dependencies = TRUE,
repos = getOption("repos"),
type = getOption("pkgType"),
upgrade = c("default", "ask", "always", "never"),
quiet = FALSE,
build = TRUE,
build_opts = c("--no-resave-data", "--no-manual", " --no-build-vignettes"),
...
)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
dependencies |
Which dependencies do you want to check? Can be a character vector (selecting from "Depends", "Imports", "LinkingTo", "Suggests", or "Enhances"), or a logical vector.
The value "soft" means the same as You can also specify dependencies from one or more additional fields, common ones include:
|
repos |
A character vector giving repositories to use. |
type |
Type of package to |
upgrade |
Should package dependencies be upgraded? One of "default", "ask", "always", or "never". "default"
respects the value of the |
quiet |
If |
build |
If |
build_opts |
Options to pass to |
... |
Additional arguments passed to |
Examples
## Not run: install_deps(".")
Is the object a package?
Description
Is the object a package?
Usage
is.package(x)
Lint all source files in a package
Description
The default linters correspond to the style guide at
https://style.tidyverse.org/, however it is possible to override any or all
of them using the linters parameter.
Usage
lint(pkg = ".", cache = TRUE, ...)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
cache |
Store the lint results so repeated lints of the same content use the previous results. Consult the lintr package to learn more about its caching behaviour. |
... |
Additional arguments passed to |
See Also
lintr::lint_package(), lintr::lint()
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:
Loads all data files in
data/. Seeload_data()for more details.Sources all R files in the R directory, storing results in environment that behaves like a regular package namespace. See
load_code()for more details.Adds a shim from
system.file()toshim_system.file()in the imports environment of the package. This ensures thatsystem.file()works with both development and installed packages despite their differing directory 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 and connects the generated DLL into R. Seepkgbuild::compile_dll()for more details.Loads any compiled translations in
inst/po.Runs
.onAttach(),.onLoad()and.onUnload()functions at the correct times.If you use testthat, will load all test helpers so you can access them interactively. devtools sets the
DEVTOOLS_LOADenvironment variable to the package name to let you check whether the helpers are run during package loading.
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
is_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 |
|
recompile |
DEPRECATED. force a recompile of DLL from source code, if
present. This is equivalent to running |
export_all |
If |
helpers |
if |
quiet |
if |
... |
Additional arguments passed to |
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.
-
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 party packages, so they will fail if they attempt to find files within your package. One potential workaround is to usefs::path_package()instead ofsystem.file(), since that understands the mechanisms that devtools uses to load packages. -
load_all()loads all packages referenced inImportsat load time, butloadNamespace()andlibrary()only load package dependencies as they are needed. -
load_all()copies all objects (not just the ones listed as exports) into the package environment. This is useful during development because it makes internal objects easy to access. To export only the objects listed as exports, useexport_all = FALSE. This more closely simulates behavior when loading an installed package withlibrary(), and can be useful for checking for missing exports.
Controlling the debug compiler flags
load_all() delegates to pkgbuild::compile_dll() to perform the actual
compilation, during which by default some debug compiler flags are
appended. If you would like to produce an optimized build instead, you can
opt out by either using debug = FALSE, setting the pkg.build_extra_flags
option to FALSE, or setting the PKG_BUILD_EXTRA_FLAGS environment variable
to FALSE. For further details see the Details section in pkgbuild::compile_dll().
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)
Return a vector of names of attached packages
Description
Return a vector of names of attached packages
Usage
loaded_packages()
Value
A data frame with columns package and path, giving the name of each package and the path it was loaded from.
Find missing s3 exports
Description
missing_s3() is deprecated because roxygen2 now provides the same
functionality. Run devtools::document() and look for
"Missing documentation for S3 method" warnings.
Usage
missing_s3(pkg = ".")
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
Find file in a package
Description
It always starts by walking up the path until it finds the root directory,
i.e. a directory containing DESCRIPTION. If it cannot find the root
directory, or it can't find the specified path, it will throw an error.
Usage
package_file(..., path = ".")
Arguments
... |
Components of the path. |
path |
Place to start search for package directory. |
Examples
## Not run:
package_file("figures", "figure_1")
## End(Not run)
Environment variables to set when calling R
Description
Devtools sets a number of environmental variables to ensure consistent
between the current R session and the new session, and to ensure that
everything behaves the same across systems. It also suppresses a common
warning on windows, and sets NOT_CRAN so you can tell that your
code is not running on CRAN. If NOT_CRAN has been set externally, it
is not overwritten.
Usage
r_env_vars()
Value
a named character vector
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
- pkgbuild
- pkgload
- sessioninfo
Release package to CRAN
Description
release() is deprecated in favour of usethis::use_release_issue().
We no longer feel confident recommending release() because we don't use it
ourselves, so there's no guarantee that it will track best practices as
they evolve over time.
If you want to programmatical submit to CRAN, you can continue to use
submit_cran().
Usage
release(pkg = ".", check = FALSE, args = NULL)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
check |
if |
args |
An optional character vector of additional command
line arguments to be passed to |
See Also
usethis::use_release_issue() to create a checklist of release
tasks that you can use in addition to or in place of release.
Custom devtools release checks
Description
This function performs additional checks prior to release. It is called
automatically by release().
Usage
release_checks(pkg = ".", built_path = NULL)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
Unload and reload package
Description
reload() is deprecated because we no longer use or recommend this
workflow. Instead, we recommend load_all() to load a package for
interactive development.
Usage
reload(pkg = ".", quiet = FALSE)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
quiet |
if |
See Also
load_all() to load a package for interactive development.
Reverse dependency tools
Description
Tools to check and notify maintainers of all CRAN and Bioconductor packages that depend on the specified package.
Usage
revdep(
pkg,
dependencies = c("Depends", "Imports", "Suggests", "LinkingTo"),
recursive = FALSE,
ignore = NULL,
bioconductor = FALSE
)
revdep_maintainers(pkg = ".")
Arguments
pkg |
Package name. This is unlike most devtools packages which take a path because you might want to determine dependencies for a package that you don't have installed. If omitted, defaults to the name of the current package. |
dependencies |
A character vector listing the types of dependencies to follow. |
recursive |
If |
ignore |
A character vector of package names to ignore. These packages will not appear in returned vector. |
bioconductor |
If |
Details
The first run in a session will be time-consuming because it must download all package metadata from CRAN and Bioconductor. Subsequent runs will be faster.
See Also
The revdepcheck package can be used to run R CMD check on all reverse dependencies.
Examples
## Not run:
revdep("ggplot2")
revdep("ggplot2", ignore = c("xkcd", "zoo"))
## End(Not run)
Run all examples in a package
Description
One of the most frustrating parts of R CMD check is getting all of your
examples to pass - whenever one fails you need to fix the problem and then
restart the whole process. This function makes it a little easier by
making it possible to run all examples from an R function.
Usage
run_examples(
pkg = ".",
start = NULL,
show = deprecated(),
run_donttest = FALSE,
run_dontrun = FALSE,
fresh = FALSE,
document = TRUE,
run = deprecated(),
test = deprecated()
)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
start |
Where to start running the examples: this can either be the
name of |
show |
DEPRECATED. |
run_donttest |
if |
run_dontrun |
if |
fresh |
if |
document |
if |
run, test |
Deprecated, see |
See Also
pkgload::run_example() to run a single example.
Save all documents in an active IDE session
Description
Helper function wrapping IDE-specific calls to save all documents in the
active session. In this form, callers of save_all() don't need to
execute any IDE-specific code. This function can be extended to include
other IDE implementations of their equivalent
rstudioapi::documentSaveAll() methods.
Usage
save_all()
Show package news
Description
show_news() is deprecated because we no longer use or recommend this
workflow.
Usage
show_news(pkg = ".", latest = TRUE, ...)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
latest |
if |
... |
other arguments passed on to |
Run a script on gist
Description
“Gist is a simple way to share snippets and pastes with others. All gists are git repositories, so they are automatically versioned, forkable and usable as a git repository.” https://gist.github.com/
Usage
source_gist(id, ..., filename = NULL, sha1 = NULL, quiet = FALSE)
Arguments
id |
either full url (character), gist ID (numeric or character of numeric). |
... |
other options passed to |
filename |
if there is more than one R file in the gist, which one to
source (filename ending in '.R')? Default |
sha1 |
The SHA-1 hash of the file at the remote URL. This is highly
recommend as it prevents you from accidentally running code that's not
what you expect. See |
quiet |
if |
See Also
Examples
## Not run:
# You can run gists given their id
source_gist(6872663)
source_gist("6872663")
# Or their html url
source_gist("https://gist.github.com/hadley/6872663")
source_gist("gist.github.com/hadley/6872663")
# It's highly recommend that you run source_gist with the optional
# sha1 argument - this will throw an error if the file has changed since
# you first ran it
source_gist(6872663, sha1 = "54f1db27e60")
# Wrong hash will result in error
source_gist(6872663, sha1 = "54f1db27e61")
#' # You can speficy a particular R file in the gist
source_gist(6872663, filename = "hi.r")
source_gist(6872663, filename = "hi.r", sha1 = "54f1db27e60")
## End(Not run)
Run a script through some protocols such as http, https, ftp, etc
Description
If a SHA-1 hash is specified with the sha1 argument, then this
function will check the SHA-1 hash of the downloaded file to make sure it
matches the expected value, and throw an error if it does not match. If the
SHA-1 hash is not specified, it will print a message displaying the hash of
the downloaded file. The purpose of this is to improve security when running
remotely-hosted code; if you have a hash of the file, you can be sure that
it has not changed. For convenience, it is possible to use a truncated SHA1
hash, down to 6 characters, but keep in mind that a truncated hash won't be
as secure as the full hash.
Usage
source_url(url, ..., sha1 = NULL)
Arguments
url |
url |
... |
other options passed to |
sha1 |
The (prefix of the) SHA-1 hash of the file at the remote URL. |
See Also
Examples
## Not run:
source_url("https://gist.github.com/hadley/6872663/raw/hi.r")
# With a hash, to make sure the remote file hasn't changed
source_url("https://gist.github.com/hadley/6872663/raw/hi.r",
sha1 = "54f1db27e60bb7e0486d785604909b49e8fef9f9")
# With a truncated hash
source_url("https://gist.github.com/hadley/6872663/raw/hi.r",
sha1 = "54f1db27e60")
## End(Not run)
Spell checking
Description
Runs a spell check on text fields in the package description file, manual pages, and optionally vignettes. Wraps the spelling package.
Usage
spell_check(pkg = ".", vignettes = TRUE, use_wordlist = TRUE)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
vignettes |
also check all |
use_wordlist |
ignore words in the package WORDLIST file |
Submit a package to CRAN
Description
This submits your package to CRAN using the web-form submission process. To complete the submission you will need respond to the email sent to the maintainer email address.
We generally recommend using this part of the process defined by
usethis::use_release_issue(); this process maximizes the chances of a successful
submission.
Usage
submit_cran(pkg = ".", args = NULL)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
args |
An optional character vector of additional command
line arguments to be passed to |
Execute testthat tests in a package
Description
-
test()runs all tests in a package. It's a shortcut fortestthat::test_dir() -
test_active_file()runstest()on the active file. -
test_coverage()computes test coverage for your package. It's a shortcut forcovr::package_coverage()pluscovr::report(). -
test_coverage_active_file()computes test coverage for the active file. It's a shortcut forcovr::file_coverage()pluscovr::report().
Usage
test(pkg = ".", filter = NULL, stop_on_failure = FALSE, export_all = TRUE, ...)
test_active_file(file = find_active_file(), ...)
test_coverage(pkg = ".", report = NULL, ...)
test_coverage_active_file(
file = find_active_file(),
filter = TRUE,
report = NULL,
export_all = TRUE,
...
)
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
filter |
If not |
stop_on_failure |
If |
export_all |
If |
... |
additional arguments passed to wrapped functions. |
file |
One or more source or test files. If a source file the corresponding test file will be run. The default is to use the active file in RStudio (if available). |
report |
How to display the coverage report.
Defaults to |
Uninstall a local development package
Description
Uses remove.packages() to uninstall the package. To uninstall a package
from a non-default library, use in combination with withr::with_libpaths().
Usage
uninstall(pkg = ".", unload = TRUE, quiet = FALSE, lib = .libPaths()[[1]])
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
unload |
if |
quiet |
If |
lib |
a character vector giving the library directories to remove the
packages from. If missing, defaults to the first element in
|
See Also
with_debug() to install packages with debugging flags set.
Other package installation:
install()
Does a package use testthat?
Description
Does a package use testthat?
Usage
uses_testthat(pkg = ".")
Set working directory
Description
wd() is deprecated because we no longer use or recommend this workflow.
Set working directory
Usage
wd(pkg = ".", path = "")
Arguments
pkg |
The package to use, can be a file path to the package or a
package object. See |
path |
path within package. Leave empty to change working directory to package directory. |