Undefined 'platformio' when starting debugger


I am trying to debug an ESP32 project. It’s worked in the past. But now when I try to run it in the debugger, I get the following in the Debug Console:

undefined 'platformio' is not recognized as an internal or external command, operable program or batch file.

The program will flash and run, but I can’t use the debugger.