Writing reproducible examples
If you need help solving a problem, the first step is to create a reproducible example. The goal of a reproducible example is to make it easier for others to help you, or for you to help yourself, by packaging your problematic code in such a way that anyone can exactly reproduce your problem. A good reproducible example is:
- Self-contained: Your code includes everything needed to reproduce your problem
- Minimal: Your example only includes code directly related to your problem
The work you put into writing a good reproducible example usually pays for itself:
- Often you will solve your own problem in the process of writing a reproducible example
- You improve your chances of getting help when your problem is easy to understand and reproduce
For tips on writing good reproducible examples, see:
Debugging interactively
See Debugging with the RStudio IDE by Jonathan McPherson and the Debugging chapter in Advanced R by Hadley Wickham.
Debugging targets pipelines
See the Debugging chapter in the targets R package user manual
Debugging GitHub Actions workflows
If you encounter problems in a GitHub Actions workflow but not locally, good luck. GitHub provides monitoring and troubleshooting documentation to get you started, but the lack of an interactive debugger can make debugging difficult. The typical approach to debugging GitHub Actions workflows is to:
- View which step caused the failure in the workflow’s logs
- Guess what caused the problem and commit the changes attempting to fix it
- Push those changes to trigger the workflow
- Hope the workflows succeeds (or repeat the process until it does)
This isn’t great. But there are a few things you can do to make it somewhat better: