Skip to content

Request: add a way to check for build-time dependencies #1788

@wch

Description

@wch

(I'm creating this issue to track a discussion that started elsewhere.) In general, it's a bad idea to run code from another package at build time, because it can bake-in some dependencies such that the resulting binary package may not work on another system, or it may not work after the build-time dependency is upgraded.

Here's an example where a package would not work if built on one machine (like a CRAN build server) and run on another:
rstudio/htmltools#22
This was a common and dangerous enough problem that we added an explicit check for it:
https://github.com/wch/htmltools/blob/9ebe77c5/R/html_dependency.R#L67-L75

Here's an example where upgrading the build-time dependency package would break the target package:
rstudio/httpuv#85 (comment)
In this case, we ended up adding an awkward workaround that will have to be maintained for a long while in the future:
https://github.com/rstudio/httpuv/blob/5b84ed80/src/RcppExports-legacy.cpp

It could save a lot of trouble if devtools could do some sort of check that warned when a package calls a function from other packages at build-time.

I should mention that there are some exceptions, where it is usually OK to do this. For example R6::R6Class() is commonly called at build time, but it is designed to encapsulate all code that will be needed in the future so it this won't cause these problems. Also, base functions like new.env() and local() should generally be OK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions