rwindowsdiffr-package

`R CMD check --as-cran` does not find `diff` on Windows


I get the following note when checking my package on Windows:

> R CMD check --as-cran mypkg_0.1.tar.gz
(...)
* checking differences from 'mypkg-Ex.Rout' to 'mypkg-Ex.Rout.save' ... OK

Message d'avis :
Dans system(paste("diff -bw", shQuote(a), shQuote(b))) : 'diff' not found
(...)

Which is not suprising since diff is a Unix utility.

How can I check the examples on Windows? (i.e. step 18 in section 1.3.1 in Writing R Extensions)

Is there a way without installing Rtools? (e.g. defining an alias with fc; I tried that without success.) I cannot install Rtools due to restrictions from our IT department.


Solution

  • The diff is included in Rtools. You should install that, from https://cloud.r-project.org/bin/windows/Rtools.

    In a comment you asked if you could do this without installing Rtools. To satisfy the command that triggered the error, you just need any executable program that can be run by calling diff from CMD. Best would be an actual diff utility, but it doesn't need to actually do anything.

    I suspect creating an empty file diff.bat would be sufficient, but I haven't tried it. However, that would mean that you aren't doing the test to compare the two files, so why bother? There are services online (on Github, at win-builder.r-project.org, on R-hub, etc.) that can do the tests for you.