22.10 Non-interactive debugging

This section will give us some useful tools when debugging, when we can’t explore interactively, it’s particularly important to spend some time making the problem as small as possible so we can iterate quickly. Sometimes callr::r(f, list(1, 2)) can be useful; this calls f(1, 2) in a fresh session, and can help to reproduce the problem.

You might also want to double check for these common issues:

  • Is the global environment different? Have you loaded different packages? Are objects left from previous sessions causing differences?

  • Is the working directory different?

  • Is the PATH environment variable, which determines where external commands (like git) are found, different?

  • Is the R_LIBS environment variable, which determines where library() looks for packages, different?