Impossible to initialize ESP-IDF project in PlatformIO (CMake git-data errors, kconfgen missing, corrupted framework)

Hello everyone,
I’m having a very persistent issue when trying to create any ESP-IDF project using PlatformIO on Windows 11 + VS Code.

I already removed and reinstalled:

  • Visual Studio Code

  • PlatformIO IDE extension

  • All PlatformIO folders (C:\Users\Gabriel\.platformio)

  • Python environments automatically created by PlatformIO

  • ESP32 platform and frameworks

Even after a completely clean installation, I still cannot initialize a project using ESP-IDF framework, regardless of version.

When I create a new project (ESP32 / NodeMCU-32S / ESP-IDF), PlatformIO starts downloading tools normally, but the build always fails with errors like:

  • CMake Error at .pio/build/nodemcu-32s/CMakeFiles/git-data/grabRef.cmake:48 (file):
    file failed to open for reading:
    …/CMakeFiles/git-data/head-ref
  • fatal: Needed a single revision
    fatal: not a git repository:
    …/framework-espidf/components/openthread/openthread/../../../.git/modules/components/openthread/openthread
  • No module named kconfgen
    Failed to run kconfgen

I need to create a simple project using ESP-IDF inside PlatformIO, but something is clearly wrong with the PlatformIO ESP-IDF framework installation or CMake configuration on my system.

If someone already solved this issue or knows which ESP-IDF version is currently stable/compatible with PlatformIO and ESP32 NodeMCU, I would appreciate guidance.

Any help is welcome!

Thank you!

I recently supplemented my ESP32 pio dev from Mac to Ubuntu and had similar errors.

In platformio.ini I wrote this comment. It may help:

;; NOTE: if you have NEWLY installed VSCode/platformio, the DEFAULT installed espressif32 is TOO old :frowning:
;; FIX: use the pioarduino link (next line) to update ~/.platformio to espressif Arduino 3.3.0 and IDF 5.5.0 just the once:
;platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
;; then use default [platform = espressif32] in all projects as installed ~/.platformio will not be overwritten.
;; If you ever have to nuke/reload ~/.platformio, use the pioarduino link again just the once