"fatal: Needed a single revision" while trying to compile for ESP32-H2

Hi all!

I’m trying to use my ESP32-H2 boards with ESPHome, given that it now support OpenThread.

I’m running ESPHome 2025.7.3 CLI from the docker container since I don’t need an always running service just to flash a few boards.

here’s my starting configuration

esphome:
  name: test-sensors
  firandly_name: Test Sensors
esp32:
  board: esp32-h2-devkitm-1
  variant: esp32h2
  framework:
    type: esp-idf

if I run

podman run --rm --prvileged -v "${PWD}:/config -it ghcr.io/esphome/esphome compile test-sensors.yaml

I got the following

INFO ESPHome 2025.7.3
INFO Reading configuration test-sensors.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing test-sensors (board: esp32-h2-devkitm-1; framework: espidf; platform: https://github.com/pioarduino/platform-espressif32/releases/download/53.03.13/platform-espressif32.zip)
-------------------------------------------------------------------------------------------------------
HARDWARE: ESP32H2 96MHz, 320KB RAM, 4MB Flash
 - framework-espidf @ 3.50302.0 (5.3.2)
 - tool-cmake @ 3.30.2
 - tool-esptoolpy @ 4.8.6
 - tool-mklittlefs @ 3.2.0
 - tool-ninja @ 1.7.1
 - tool-riscv32-esp-elf-gdb @ 14.2.0+20240403
 - tool-xtensa-esp-elf-gdb @ 14.2.0+20240403
 - toolchain-esp32ulp @ 2.35.0-20220830
 - toolchain-riscv32-esp @ 13.2.0+20240530
Installing standard Python dependencies

# dependencies are installed without problems here

Reading CMake configuration...
-- Building ESP-IDF components for target esp32h2
Processing 1 dependencies:
[1/1] idf (5.3.2)
-- Project sdkconfig file /config/.esphome/build/test-sensors/sdkconfig.test-sensors
-- Adding linker script /config/.esphome/platformio/packages/framework-espidf/components/riscv/ld/rom.api.ld
-- App "test-sensors" version: 2025.7.3
-- Adding linker script [omitted for brevity]
-- Components: [omitted for brevity]
-- Component paths: [omitted for brevity]
-- Configuring incomplete, errors occurred!

CMake Error at .pioenvs/test-sensors/CMakeFiles/git-data/grabRef.cmake:48 (file):
  file failed to open for reading (No such file or directory):

    /config/.esphome/build/test-sensors/.pioenvs/test-sensors/CMakeFiles/git-data/head-ref
Call Stack (most recent call first):
  /config/.esphome/platformio/packages/framework-espidf/tools/cmake/third_party/GetGitRevisionDescription.cmake:83 (include)
  /config/.esphome/platformio/packages/framework-espidf/tools/cmake/third_party/GetGitRevisionDescription.cmake:93 (get_git_head_revision)
  /config/.esphome/platformio/packages/framework-espidf/tools/cmake/build.cmake:70 (git_describe)
  /config/.esphome/platformio/packages/framework-espidf/tools/cmake/build.cmake:242 (__build_get_idf_git_revision)
  /config/.esphome/platformio/packages/framework-espidf/tools/cmake/idf.cmake:52 (__build_init)
  /config/.esphome/platformio/packages/framework-espidf/tools/cmake/project.cmake:29 (include)
  CMakeLists.txt:2 (include)

fatal: Needed a single revision
fatal: Needed a single revision

===================================== [FAILED] Took 14.97 seconds =====================================

indeed head-ref is not present at that folder.

I tried to change esp-idf version and platform_version to more recent version (like 5.4.2 and 54.03.21 respectively), but the error stays the same.

I’ve tried to use the clean command and remove the .esphome folder entirely, but nothing changed.

Is there something obvious that I’m missing?

…aaaand obviously I found the solution just after posting this :sweat_smile:

The hint came from this:

And the cause was that my configuration files were in a git folder. I’ve moved them in a subfolder and only mount it as /config inside the container, problem solved!