The only difference I see from the working to the non-working build is that the non-working build includes the library |-- <WiFi> 1.2.7. Try adding lib_ignore = WiFi to the platformio.ini to prevent this.