Hi all, Does anyone have any suggestions for debugging the execution of examples by R CMD check? The examples work fine when I run them from a live R prompt, but I get errors when they are run by R CMD check. Thanks, Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/
On 06/29/2010 11:56 PM, Hadley Wickham wrote:> Does anyone have any suggestions for debugging the execution of > examples by R CMD check? The examples work fine when I run them from > a live R prompt, but I get errors when they are run by R CMD check.Not a real tip, but when it occurs I immediately check for namespace issues (which often turn out to be the origin). Things I do are - verify all packages involved have namespaces; - load all packages (i.e. put explicitly on the search path) to detect masking issues; - check all imports and exports and if relevant turn package imports into individual function imports to have a more fine-grained view. Agreed this is a very indirect way, but at times faster than trying to interpret the error message. Best, Tobias
[Apologies for breaking the thread, I deleted the message before starting this reply] Dear Hadley, R CMD check produces a foo-Ex.R file where foo is the package name. You could start by sourcing that file in R --vanilla and see where it fails and also use standard debugging tools in R from there (i.e. drop into a debugger on error). HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
On Wed, Jun 30, 2010 at 3:26 AM, Hadley Wickham <hadley at rice.edu> wrote:> Hi all, > > Does anyone have any suggestions for debugging the execution of > examples by R CMD check? ?The examples work fine when I run them from > a live R prompt, but I get errors when they are run by R CMD check.'R CMD check pkg' will produce a pkg.Rcheck/pkg-Ex.R file that collects the examples into a single file (and also does other things). You could try running that file interactively to see if the error is reproduced. -Deepayan
> R CMD check produces a foo-Ex.R file where foo is the package name. You > could start by sourcing that file in R --vanilla and see where it fails > and also use standard debugging tools in R from there (i.e. drop into a > debugger on error).I knew about the foo-Ex.R file, but unfortunately running that produced no errors. I ended up resorting to inserting print statements every few lines to narrow down the exact location of the problem, which revealed that my code assumed options(keep.source = TRUE) but during R CMD check, options(keep.source = FALSE). Hopefully this type of problem will be easier to sort out with the new pure R R CMD check in 2.11. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/