Unable to start esp-idf project, cmake has some errors during setup

I am trying to start a basic project for a ESP32-PICO using PlatformIO

My platformio.ini looks like

[platformio]
src_dir = ./

[env:testbench]
platform = espressif32
framework = espidf
board = pico32

My sdkconfig.defaults looks like

CONFIG_AUTOSTART_ARDUINO=y
# CONFIG_WS2812_LED_ENABLE is not set
CONFIG_FREERTOS_HZ=1000
CONFIG_MBEDTLS_PSK_MODES=y
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y

The source code looks like

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_log.h"

void app_main(void)
{
    while (true)
    {
        printf("Hello World\n");
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}

The root of the project is indeed a git repo, git status returns the correct status, it does have a commit, and git rev-parse HEAD returns a hash. The git installation was updated to the latest as of today.

When I click build, the full error message is

Executing task: C:\Users\frank\.platformio\penv\Scripts\platformio.exe run --environment testbench 

Processing testbench (platform: espressif32; framework: espidf; board: pico32)
---------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/pico32.html
PLATFORM: Espressif 32 (6.8.1) > ESP32 Pico Kit
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-espidf @ 3.50300.0 (5.3.0) 
 - tool-cmake @ 3.16.4 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - tool-idf @ 1.0.1 
 - tool-mconf @ 1.4060000.20190628 (406.0.0) 
 - tool-ninja @ 1.9.0 
 - tool-riscv32-esp-elf-gdb @ 11.2.0+20220823
 - tool-xtensa-esp-elf-gdb @ 11.2.0+20230208
 - toolchain-esp32ulp @ 1.23800.240113 (2.38.0)
 - toolchain-xtensa-esp-elf @ 13.2.0+20240530
Reading CMake configuration...
-- git rev-parse returned 'fatal: not a git repository (or any of the parent directories): .git'
-- Building ESP-IDF components for target esp32
-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.46.0.windows.1")
-- Configuring incomplete, errors occurred!
See also "D:/GithubRepos/Shrew-TestBench/.pio/build/testbench/CMakeFiles/CMakeOutput.log".

fatal: not a git repository (or any of the parent directories): .git
CMake Error at C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/component.cmake:225 (message): 
  CMake Warning (dev) at .pio/build/testbench/build_properties.temp.cmake:8:

    Syntax Warning in cmake code at column 106



    Argument not separated from preceding token by whitespace.

  Call Stack (most recent call first):

    C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/scripts/component_get_requirements.cmake:3 (include)

  This warning is for project developers.  Use -Wno-dev to suppress it.



  CMake Error at
  C:/Users/frank/.platformio/packages/tool-cmake/share/cmake-3.16/Modules/ExternalProject.cmake:1029
  (define_property):

    define_property command is not scriptable

  Call Stack (most recent call first):

    C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/kconfig.cmake:1 (include)
    C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/idf.cmake:43 (include)
    C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/project.cmake:29 (include)
    CMakeLists.txt:2 (include)
    C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/scripts/component_get_requirements.cmake:107 (include)
    C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/scripts/component_get_requirements.cmake:127 (__component_get_requirements)





Call Stack (most recent call first):
  C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/build.cmake:586 (__component_get_requirements)
  C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/project.cmake:710 (idf_build_process)       
  CMakeLists.txt:3 (project)



========================================= [FAILED] Took 2.45 seconds =========================================

 *  The terminal process "C:\Users\frank\.platformio\penv\Scripts\platformio.exe 'run', '--environment', 'testbench'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: C:\Users\frank\.platformio\penv\Scripts\platformio.exe run --environment testbench 

Processing testbench (platform: espressif32; framework: espidf; board: pico32)
---------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/pico32.html
PLATFORM: Espressif 32 (6.8.1) > ESP32 Pico Kit
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-espidf @ 3.50300.0 (5.3.0)
 - tool-cmake @ 3.16.4
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - tool-idf @ 1.0.1
 - tool-mconf @ 1.4060000.20190628 (406.0.0)
 - tool-ninja @ 1.9.0
 - tool-riscv32-esp-elf-gdb @ 11.2.0+20220823
 - tool-xtensa-esp-elf-gdb @ 11.2.0+20230208
 - toolchain-esp32ulp @ 1.23800.240113 (2.38.0)
 - toolchain-xtensa-esp-elf @ 13.2.0+20240530
Reading CMake configuration...
-- git rev-parse returned 'fatal: not a git repository (or any of the parent directories): .git'
-- Building ESP-IDF components for target esp32
-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.46.0.windows.1")
-- Configuring incomplete, errors occurred!
See also "D:/GithubRepos/Shrew-TestBench/.pio/build/testbench/CMakeFiles/CMakeOutput.log".

fatal: not a git repository (or any of the parent directories): .git
CMake Error at C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/component.cmake:225 (message): 
  CMake Warning (dev) at .pio/build/testbench/build_properties.temp.cmake:8:

    Syntax Warning in cmake code at column 106



    Argument not separated from preceding token by whitespace.

  Call Stack (most recent call first):

    C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/scripts/component_get_requirements.cmake:3 (include)

  This warning is for project developers.  Use -Wno-dev to suppress it.



  CMake Error at
  C:/Users/frank/.platformio/packages/tool-cmake/share/cmake-3.16/Modules/ExternalProject.cmake:1029
  (define_property):

    define_property command is not scriptable

  Call Stack (most recent call first):

    C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/kconfig.cmake:1 (include)
    C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/idf.cmake:43 (include)
    C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/project.cmake:29 (include)
    CMakeLists.txt:2 (include)
    C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/scripts/component_get_requirements.cmake:107 (include)
    C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/scripts/component_get_requirements.cmake:127 (__component_get_requirements)





Call Stack (most recent call first):
  C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/build.cmake:586 (__component_get_requirements)
  C:/Users/frank/.platformio/packages/framework-espidf/tools/cmake/project.cmake:710 (idf_build_process)       
  CMakeLists.txt:3 (project)



========================================= [FAILED] Took 2.38 seconds =========================================

I have completely wiped out the .platformio directory from my user directory already, all the platforms and packages have been reinstalled, and the issue was not resolved.

Reinstalling git did not resolve the issue.

I have read all of these search results and none of them had a solution that worked

Please help! Thanks!

EDIT: Interesting… I installed the ESP-IDF extension for VSCode and then tried to build a template project. I get the same error about git

I don’t think this bodes well. There’s sepcial handling for the src/ directory (or main/) directory. can you remove that and use the standard folder structure?

https://github.com/platformio/platform-espressif32/tree/develop/examples/espidf-hello-world

Delete the whole .pio folder after doing so to get a clean build.

That actually fixed it, making a proper src directory and using it. Wow

Thanks!!!