rcmdcheck icon indicating copy to clipboard operation
rcmdcheck copied to clipboard

`rcmdcheck::check()` fails on Windows when Rtools is not installed

Open maxsutton opened this issue 3 years ago • 2 comments

Description

rcmdcheck::check() now throws an error and stops checking the package on Windows when Rtools is not installed.

Previous working behaviour

Previously (rcmdcheck v1.3.3), check() would issue a warning about missing Rtools, but still complete the checking of the package.

Cause

The cause seems to be the pkgbuild::local_build_tools() call introduced for #111 , which was seemingly done for convenience.

Here is the line in the latest version, where the issue remains: https://github.com/r-lib/rcmdcheck/blob/a38200c997f58478c8d3e2c4d2dd5e6244dabcba/R/package.R#L145

local_build_tools() has an argument required which is TRUE by default and is called as such. The description of the required argument is:

If TRUE, and build tools are not available, will throw an error. Otherwise will attempt to run code without them

Possible solutions

There are a couple of ways that I've thought of to fix this regression. There are likely others:

  • rcmdcheck::check() could call local_build_tools(required = FALSE), but I don't know if this would break the new intended behaviour introduced in #111.

  • An option could be added which would set the required argument to false: e.g. options("rcmdcheck.rtools.required" = FALSE)

maxsutton avatar Dec 14 '21 22:12 maxsutton

As a workaround, you can build the source package first, and then call rcmdcheck::rcmdcheck() on that.

gaborcsardi avatar Dec 15 '21 04:12 gaborcsardi

As a workaround, you can build the source package first, and then call rcmdcheck::rcmdcheck() on that.

I tried the suggested workaround (output below), but rcmdcheck::rcmdcheck() still threw the error. This is because pkgbuild::local_build_tools() is called regardless of whether a package tarball or directory is given.

Another concern is that such a workaround would be different to well-documented and recommended workflows (e.g. r-pkgs Automated checking), which could make it difficult for newer contributors.

Code

> pkg <- devtools::build()
WARNING: Rtools is required to build R packages, but is not currently installed.

Please download and install Rtools 4.0 from https://cran.r-project.org/bin/windows/Rtools/.
√  checking for file '/path/to/pkg/DESCRIPTION' (827ms)
-  preparing 'pkg': (3.3s)
√  checking DESCRIPTION meta-information ... 
-  installing the package to build vignettes
√  creating vignettes (14.6s)
-  checking for LF line-endings in source and make files and shell scripts (2.2s)
-  checking for empty or unneeded directories
-  building 'pkg_0.0.0.9000.tar.gz'
   
> rcmdcheck::rcmdcheck(pkg)
WARNING: Rtools is required to build R packages, but is not currently installed.

Please download and install Rtools 4.0 from https://cran.r-project.org/bin/windows/Rtools/.
Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.

maxsutton avatar Dec 16 '21 00:12 maxsutton