Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug R-Shiny code with VS Code

Is there any way to debug Shiny (R) inside VS Code? I can easily debug Shiny apps inside RStudio but I like to code inside VS Code so looking for the way to debug R code inside VS Code.

like image 236
Saurabh Palatkar Avatar asked May 29 '26 02:05

Saurabh Palatkar


1 Answers

Seems, shiny can be debugged in VSCode using browser-statements 🙌

Prerequisites

  • Setup this VSCode extensions (VSCode R Guide)
    • R (by Yuki Ueda)
    • R Debugger
  • Use a default app structure (see docs of appDir when running ?shiny::runApp for possible setups)
  • Set your VSCode workspace to the R projects root (e.g. File -> Open Folder... -> myProject)

Debugging

  • Set your breakpoints using browser() (RStudio Article)
  • Run R-Debugger in Launch R-Workspace mode
  • Execute shiny::runApp() in the Debug Console as soon the Debugger pauses
  • Your app should fire up in a browser and the breakpoints pause the execution 🎉

Further Ressources

  • VSCode Article on debugging (can be very helpfull)
  • Issue on this topic in the VSCode-R-Debugger repo
like image 119
Mac Jo Avatar answered May 31 '26 15:05

Mac Jo