How to fix PlatformIO ESP32 missing SConscript file: platformio-build.py

Problem:

You are trying to compile your PlatformIO project using arduino-espressif32 Version 3.x as the framework but you get the following error:

*** missing SConscript file '/home/user/.platformio/packages/framework-arduinoespressif32/tools/platformio-build.py'
File "/home/user/.platformio/platforms/espressif32/builder/frameworks/arduino.py", line 49, in <module>

Solution:

Currently, PlatformIO does not work out-of the box with the new arduino-espressif32 framework version 3.x.

The recommended solution is to use pioarduino:

platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.10/platform-espressif32.zip

Alternatively, you can fix this by downgrading the framework to version 2.x:

platform = espressif32
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.16