Find Tools Needed to Build R Packages

Provides functions used to build R packages. Locates compilers needed to build R packages on various platforms and ensures the PATH is configured appropriately so R can use them.

Travis-CI Build Status AppVeyor Build Status Coverage status

The goal of pkgbuild is to make it easy to build packages with compiled code. It provides tools to configure your R session, and check that everything is working ok. If you are using RStudio, it also helps you trigger automatic install of the build tools.


You can install pkgbuild from github with:

# install.packages("devtools")


# Check that you have the build tools installed
pkgbuild::check_build_tools(debug = TRUE)
# Build a package
# Run your own code in an environment guaranteed to 
# have build tools available


pkgbuild 1.0.2

  • build() and compile_dll() gain a register_routines argument, to automatically register C routines with tools::package_native_routines_registration_skeleton() (#50)

  • build() will now warn if trying to build packages on R versions <= 3.4.2 on Windows with a space in the R installation directory (#49)

  • build() will now message if a build contains long paths, which are unsupported on windows (#48)

  • compile_dll() no longer doubles output, a regression caused by the styling callback. (

  • build() output is now styled like that in the rcmdcheck package (

  • build() no longer sets compile flags (#46)

pkgbuild 1.0.1

  • compile_dll() now does not supply compiler flags if there is an existing user defined Makevars file.

  • local_build_tools() function added to provide a deferred equivalent to with_build_tools(). So you can add rtools to the PATH until the end of a function body.

pkgbuild 1.0.0

  • Add metadata to support Rtools 3.5 (#38).

  • build() only uses the --no-resave-data argument in R CMD build if the --resave-data argument wasn't supplied by the user (@theGreatWhiteShark, #26)

  • build() now cleans existing vignette files in inst/doc if they exist. (#10)

  • clean_dll() also deletes symbols.rds which is created when compile_dll() is run inside of R CMD check.

  • First argument of all functions is now path rather than pkg.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.0.2 by Jim Hester, 4 months ago

Report a bug at

Browse source code at

Authors: Hadley Wickham [aut] , Jim Hester [aut, cre] , RStudio [cph]

Documentation:   PDF Manual  

GPL-3 license

Imports callr, cli, crayon, desc, prettyunits, R6, rprojroot, withr

Suggests Rcpp, testthat, covr

Imported by RInno, devtools, fakemake, pkgload, rcmdcheck, rstan.

Suggested by Rmosek, remotes.

See at CRAN