"platformio: command not found" out of the blue

Hello !

I haven’t used PlatformIO IDE in about 2 months and now I can’t use terminal commands because apparently they do not exist.
Nothing changed on this PC because I haven’t opened it since the beginning of March. VSC is still running on an old version (1.42.1).

I am trying to upload files into an ESP32 but running pio run -t uploadfs returns Command 'pio' not found, but there are 15 similar ones..
And running platformio update returns platformio: command not found.

Also, I can’t upload code to an ESP because there is a missing library in a finished project. I have finished this projects months ago and it worked wonders. I have made no alteration to it, yet I get:

.pio/libdeps/esp32doit-devkit-v1/Adafruit BusIO_ID6214/Adafruit_I2CDevice.h:1:18: fatal error: Wire.h: No such file or directory

I think that something happened with PIO which is messing with the pathing of everything.

I have never had this problem before.

I have uninstalled and installed PIO extensions and the result is the same.
I have deleted .vscode and .pio folders from the respective project and then closed and re-opened VSC, but with no luck.

What do you think happened ?

I have added Wire to the lib_deps inside platformio.ini to try and continue working with the project, but now I have other “missing” headers. They weren’t missing before. This is getting really frustrating. All the headers are there as this is a working and implemented project but all of a sudden PIO decided to screw it all up.

To fix the Wire.h message, I’d suggest you remove Wire from lib_deps (it’s a framework/core provided library, so should never be added there), and instead trying adding #include <Wire.h> above the line in your main.cpp that includes the Adafruit libraries (I’m not sure which one specifically). I usually ensure #include <Arduino.h> is the first line in the list of includes, so if you’ve done the same, you could add insert it on the next line.

As to why PIO is now not found, that’s an odd one… is this the same when you use the PlatformIO icons in the status bar, or in the PIO sidebar panel? If not, try specifically opening a PIO Terminal (i.e. the last of the PIO icons on the status bar), as VSCode is probably opening a terminal that doesn’t know about PlatformIO on startup which is downright annoying.