Skip to content

esphome: fails to build projects based on esp-idf framework due to platformio #442676

Closed

Description

@ereslibre

Nixpkgs version

  • Unstable (25.11)

Describe the bug

When a project uses the esp-idf framework, it fails to build. If esphome compile is run more than once, two different errors are shown, one in the clean run, the other in the rest.

Steps to reproduce

  • Write a configuration.yaml file with contents:

    esphome:
      name: someproject
    
    esp32:
      board: az-delivery-devkit-v4
      framework:
        type: esp-idf
    
    # Enable logging
    logger:
    
    # Enable Home Assistant API
    api:
      password: ""
    
    ota:
      - platform: esphome
        password: ""
    
    wifi:
      ssid: "somewifi"
      password: "somepassword"
    

    The most important bit in this case is esp32.framework.type: esp-idf, is what triggers the IDF platform to be used instead of the Arduino one.

  • Run:
    nix run github:NixOS/nixpkgs/c5f7acaaf14cd126bbccd30c6e40c32366a66e2d#esphome compile configuration.yaml

Expected behaviour

The project builds, same as when using the Arduino framework.

Screenshots

No response

Relevant log output

First run error
❯ nix run github:NixOS/nixpkgs/c5f7acaaf14cd126bbccd30c6e40c32366a66e2d#esphome compile configuration.yaml
INFO ESPHome 2025.8.4
INFO Reading configuration configuration.yaml...
INFO Generating C++ source...
INFO Core config or version changed, cleaning build files...
INFO Compiling app...
**************************************************************************************************************************************************************************************************
If you like PlatformIO, please:
- star it on GitHub > https://github.com/platformio/platformio-core
- follow us on LinkedIn to stay up-to-date on the latest project news > https://www.linkedin.com/company/platformio/
- try PlatformIO IDE for embedded development > https://platformio.org/platformio-ide
**************************************************************************************************************************************************************************************************

Processing someproject (board: az-delivery-devkit-v4; framework: espidf; platform: https://github.com/pioarduino/platform-espressif32/releases/download/54.03.21-2/platform-espressif32.zip)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Platform Manager: Installing https://github.com/pioarduino/platform-espressif32/releases/download/54.03.21-2/platform-espressif32.zip
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Platform Manager: [email protected] has been installed!
Tool Manager: Installing https://github.com/pioarduino/esp_install/releases/download/v5.3.1/esp_install-v5.3.1.zip
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: [email protected] has been installed!
Tool Manager: Installing https://github.com/pioarduino/esp-idf/releases/download/v5.4.2/esp-idf-v5.4.2.zip
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: [email protected] has been installed!
Tool Manager: Installing https://github.com/pioarduino/registry/releases/download/0.0.1/xtensa-esp-elf-14.2.0_20241119.zip
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: [email protected]+20241119 has been installed!
Tool Manager: Installing espressif/toolchain-esp32ulp @ 2.35.0-20220830
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: [email protected] has been installed!
Tool Manager: Installing https://github.com/pioarduino/registry/releases/download/0.0.1/esptoolpy-v5.0.2.zip
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: [email protected] has been installed!
Tool Manager: Installing https://github.com/pioarduino/registry/releases/download/0.0.1/mklittlefs-3.2.0.zip
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: [email protected] has been installed!
Tool Manager: Installing https://github.com/pioarduino/registry/releases/download/0.0.1/cmake-3.30.2.zip
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: [email protected] has been installed!
Tool Manager: Installing https://github.com/pioarduino/registry/releases/download/0.0.1/esp-rom-elfs-20241011.zip
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: [email protected] has been installed!
Tool Manager: Installing https://github.com/pioarduino/registry/releases/download/0.0.1/ninja-1.13.1.zip
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: [email protected] has been installed!
Tool Manager: Installing https://github.com/pioarduino/registry/releases/download/0.0.1/scons-4.8.1.zip
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: [email protected] has been installed!
Tool Manager: Installing platformio/tool-scons @ ~4.40801.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: [email protected] has been installed!
idf_tools.py installation failed
idf_tools.py installation failed
idf_tools.py installation failed
idf_tools.py installation failed
idf_tools.py installation failed
idf_tools.py installation failed
Verbose mode can be enabled via `-v, --verbose` option
Tool Manager: Installing file:///home/ereslibre/.platformio/tools/tool-esptoolpy
Tool Manager: [email protected] has been installed!
Tool Manager: Installing file:///home/ereslibre/.platformio/tools/toolchain-xtensa-esp-elf
Tool Manager: [email protected]+20241119 has been installed!
Tool Manager: Installing file:///home/ereslibre/.platformio/tools/tool-mklittlefs
Tool Manager: [email protected] has been installed!
Tool Manager: Installing file:///home/ereslibre/.platformio/tools/tool-cmake
Tool Manager: [email protected] has been installed!
Tool Manager: Installing file:///home/ereslibre/.platformio/tools/tool-ninja
Tool Manager: [email protected] has been installed!
Tool Manager: Installing file:///home/ereslibre/.platformio/tools/tool-esp-rom-elfs
Tool Manager: [email protected] has been installed!
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/az-delivery-devkit-v4.html
PLATFORM: Espressif 32 (54.3.21) > AZ-Delivery ESP-32 Dev Kit C V4
HARDWARE: ESP32 240MHz, 520KB 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.50402.0 (5.4.2)
 - tool-scons @ 4.40801.0 (4.8.1)
 - toolchain-esp32ulp @ 2.35.0-20220830
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType:
  File "/nix/store/0jf6x26nwzgx9d616qiw163d3jgm404k-platformio-6.1.18/lib/python3.13/site-packages/platformio/builder/main.py", line 175:
    env.SConscript("$BUILD_SCRIPT")
  File "/home/ereslibre/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Script/SConscript.py", line 620:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/ereslibre/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Script/SConscript.py", line 280:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/ereslibre/.platformio/platforms/espressif32/builder/main.py", line 526:
    target_elf = env.BuildProgram()
  File "/home/ereslibre/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Util/envs.py", line 252:
    return self.method(*nargs, **kwargs)
  File "/nix/store/0jf6x26nwzgx9d616qiw163d3jgm404k-platformio-6.1.18/lib/python3.13/site-packages/platformio/builder/tools/piobuild.py", line 62:
    env.ProcessProgramDeps()
  File "/home/ereslibre/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Util/envs.py", line 252:
    return self.method(*nargs, **kwargs)
  File "/nix/store/0jf6x26nwzgx9d616qiw163d3jgm404k-platformio-6.1.18/lib/python3.13/site-packages/platformio/builder/tools/piobuild.py", line 142:
    env.BuildFrameworks(env.get("PIOFRAMEWORK"))
  File "/home/ereslibre/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Util/envs.py", line 252:
    return self.method(*nargs, **kwargs)
  File "/nix/store/0jf6x26nwzgx9d616qiw163d3jgm404k-platformio-6.1.18/lib/python3.13/site-packages/platformio/builder/tools/piobuild.py", line 352:
    SConscript(env.GetFrameworkScript(name), exports="env")
  File "/home/ereslibre/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Script/SConscript.py", line 684:
    return method(*args, **kw)
  File "/home/ereslibre/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Script/SConscript.py", line 620:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/ereslibre/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Script/SConscript.py", line 280:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/ereslibre/.platformio/platforms/espressif32/builder/frameworks/espidf.py", line 151:
    assert os.path.isdir(TOOLCHAIN_DIR)
  File "<frozen genericpath>", line 51:

================================================================================== [FAILED] Took 32.33 seconds ==================================================================================
Second run error
❯ nix run github:NixOS/nixpkgs/c5f7acaaf14cd126bbccd30c6e40c32366a66e2d#esphome compile configuration.yaml
INFO ESPHome 2025.8.4
INFO Reading configuration configuration.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing someproject (board: az-delivery-devkit-v4; framework: espidf; platform: https://github.com/pioarduino/platform-espressif32/releases/download/54.03.21-2/platform-espressif32.zip)
-----------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/az-delivery-devkit-v4.html
PLATFORM: Espressif 32 (54.3.21) > AZ-Delivery ESP-32 Dev Kit C V4
HARDWARE: ESP32 240MHz, 520KB 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.50402.0 (5.4.2)
 - tool-cmake @ 3.30.2
 - tool-esp-rom-elfs @ 2024.10.11
 - tool-esptoolpy @ 5.0.2
 - tool-mklittlefs @ 3.2.0
 - tool-ninja @ 1.13.1
 - tool-scons @ 4.40801.0 (4.8.1)
 - toolchain-esp32ulp @ 2.35.0-20220830
 - toolchain-xtensa-esp-elf @ 14.2.0+20241119
Creating a new virtual environment for IDF Python dependencies
Installing ESP-IDF's Python dependencies
Reading CMake configuration...
-- Found Git: /nix/store/4q2dd3sf6xq9bky0aq2wyp2pf958j0rz-git-2.51.0/bin/git (found version "2.51.0")
-- git rev-parse returned 'fatal: not a git repository (or any of the parent directories): .git'
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /Users/ereslibre/.platformio/packages/toolchain-xtensa-esp-elf/bin/xtensa-esp32-elf-gcc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Users/ereslibre/.platformio/packages/toolchain-xtensa-esp-elf/bin/xtensa-esp32-elf-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Users/ereslibre/.platformio/packages/toolchain-xtensa-esp-elf/bin/xtensa-esp32-elf-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building ESP-IDF components for target esp32
Dependencies lock doesn't exist, solving dependencies.
..NOTICE: Updating lock file at /Users/ereslibre/sometest/.esphome/build/someproject/dependencies.lock
Processing 2 dependencies:
[1/2] espressif/mdns (1.8.2)
[2/2] idf (5.4.2)
-- Project sdkconfig file /Users/ereslibre/sometest/.esphome/build/someproject/sdkconfig.someproject
-- Configuring incomplete, errors occurred!

fatal: not a git repository (or any of the parent directories): .git
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/ereslibre/.platformio/penv/.espidf-5.4.2/lib/python3.13/site-packages/kconfgen/__main__.py", line 5, in <module>
    from .core import main
  File "/Users/ereslibre/.platformio/penv/.espidf-5.4.2/lib/python3.13/site-packages/kconfgen/core.py", line 29, in <module>
    import esp_idf_kconfig.gen_kconfig_doc as gen_kconfig_doc
  File "/Users/ereslibre/.platformio/penv/.espidf-5.4.2/lib/python3.13/site-packages/esp_idf_kconfig/gen_kconfig_doc.py", line 14, in <module>
    import kconfiglib.core as kconfiglib
ModuleNotFoundError: No module named 'kconfiglib.core'; 'kconfiglib' is not a package
CMake Error at /Users/ereslibre/.platformio/packages/framework-espidf/tools/cmake/kconfig.cmake:209 (message):
  Failed to run kconfgen
  (/Users/ereslibre/.platformio/penv/.espidf-5.4.2/bin/python;-m;kconfgen;--list-separator=semicolon;--kconfig;/Users/ereslibre/.platformio/packages/framework-espidf/Kconfig;--sdkconfig-rename;/Users/ereslibre/.platformio/packages/framework-espidf/sdkconfig.rename;--config;/Users/ereslibre/sometest/.esphome/build/someproject/sdkconfig.someproject;--env-file;/Users/ereslibre/sometest/.esphome/build/someproject/.pioenvs/someproject/config.env).
  Error 1
Call Stack (most recent call first):
  /Users/ereslibre/.platformio/packages/framework-espidf/tools/cmake/build.cmake:691 (__kconfig_generate_config)
  /Users/ereslibre/.platformio/packages/framework-espidf/tools/cmake/project.cmake:718 (idf_build_process)
  CMakeLists.txt:3 (project)



================================================================== [FAILED] Took 9.66 seconds ==================================================================

Additional context

No response

System metadata

❯ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.12.42, NixOS, 25.11 (Xantusia), 25.11.20250910.ab0f360`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.28.5`
 - nixpkgs: `/nix/store/9rfm3gjhphdvi7qnzdsi7piw1gi4c8vp-source`

Notify maintainers

@mweinelt @makefu @mogorman


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a 👍 reaction to issues you find important.

Activity

  1. added
    0.kind: bug
    on Sep 13, 2025
  2. hatch01 commented on Sep 14, 2025

    @hatch01
    Contributor

    Is this a new issue, or has this never worked?

  3. hatch01 commented on Sep 14, 2025

    @hatch01
    Contributor

    Got using esphome from stable :

    INFO ESPHome 2025.4.2
    INFO Reading configuration /var/lib/esphome/portail.yaml...
    INFO Generating C++ source...
    Traceback (most recent call last):
      File "/nix/store/b7b3avn6a9wq5l5n1bn1zrqcil3my0j8-esphome-2025.4.2/bin/.esphome-wrapped", line 9, in <module>
        sys.exit(main())
                 ^^^^^^
      File "/nix/store/b7b3avn6a9wq5l5n1bn1zrqcil3my0j8-esphome-2025.4.2/lib/python3.12/site-packages/esphome/__main__.py", line 1081, in main
        return run_esphome(sys.argv)
               ^^^^^^^^^^^^^^^^^^^^^
      File "/nix/store/b7b3avn6a9wq5l5n1bn1zrqcil3my0j8-esphome-2025.4.2/lib/python3.12/site-packages/esphome/__main__.py", line 1068, in run_esphome
        rc = POST_CONFIG_ACTIONS[args.command](args, config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/nix/store/b7b3avn6a9wq5l5n1bn1zrqcil3my0j8-esphome-2025.4.2/lib/python3.12/site-packages/esphome/__main__.py", line 462, in command_compile
        exit_code = write_cpp(config)
                    ^^^^^^^^^^^^^^^^^
      File "/nix/store/b7b3avn6a9wq5l5n1bn1zrqcil3my0j8-esphome-2025.4.2/lib/python3.12/site-packages/esphome/__main__.py", line 214, in write_cpp
        return write_cpp_file()
               ^^^^^^^^^^^^^^^^
      File "/nix/store/b7b3avn6a9wq5l5n1bn1zrqcil3my0j8-esphome-2025.4.2/lib/python3.12/site-packages/esphome/__main__.py", line 232, in write_cpp_file
        writer.write_cpp(code_s)
      File "/nix/store/b7b3avn6a9wq5l5n1bn1zrqcil3my0j8-esphome-2025.4.2/lib/python3.12/site-packages/esphome/writer.py", line 339, in write_cpp
        copy_src_tree()
      File "/nix/store/b7b3avn6a9wq5l5n1bn1zrqcil3my0j8-esphome-2025.4.2/lib/python3.12/site-packages/esphome/writer.py", line 305, in copy_src_tree
        copy_files()
      File "/nix/store/b7b3avn6a9wq5l5n1bn1zrqcil3my0j8-esphome-2025.4.2/lib/python3.12/site-packages/esphome/components/esp32/__init__.py", line 812, in copy_files
        repo_dir, _ = git.clone_or_update(
                      ^^^^^^^^^^^^^^^^^^^^
      File "/nix/store/b7b3avn6a9wq5l5n1bn1zrqcil3my0j8-esphome-2025.4.2/lib/python3.12/site-packages/esphome/git.py", line 92, in clone_or_update
        old_sha = run_git_command(["git", "rev-parse", "HEAD"], str(repo_dir))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/nix/store/b7b3avn6a9wq5l5n1bn1zrqcil3my0j8-esphome-2025.4.2/lib/python3.12/site-packages/esphome/git.py", line 32, in run_git_command
        raise cv.Invalid(err_str)
    voluptuous.error.Invalid: fatal : argument 'HEAD' ambigu : révision inconnue ou chemin inexistant.
    Utilisez '--' pour séparer les chemins des révisions, comme ceci :
    'git <commande> [<révision>...] -- [<chemin>...]'
    
  4. mweinelt commented on Sep 14, 2025

    @mweinelt
    Member

    @hatch01 unrelated.
    @ereslibre That's a platformio packaging issue, not esphome.

  5. changed the title [-]esphome: fails to build projects based on `esp-idf` framework[/-] [+]esphome: fails to build projects based on `esp-idf` framework due to platformio[/+] on Sep 15, 2025
  6. ereslibre commented on Sep 15, 2025

    @ereslibre
    MemberAuthor

    @mweinelt ok thanks, I have added platformio maintainers in the loop.

  7. techyporcupine commented on Sep 25, 2025

    @techyporcupine
    Contributor

    Bumping this; having the issue as well.

    TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType:
      File "/nix/store/0jf6x26nwzgx9d616qiw163d3jgm404k-platformio-6.1.18/lib/python3.13/site-packages/platformio/builder/main.py", line 175:
        env.SConscript("$BUILD_SCRIPT")
      File "/home/techyporcupine/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Script/SConscript.py", line 620:
        return _SConscript(self.fs, *files, **subst_kw)
      File "/home/techyporcupine/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Script/SConscript.py", line 280:
        exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
      File "/home/techyporcupine/.platformio/platforms/espressif32/builder/main.py", line 526:
        target_elf = env.BuildProgram()
      File "/home/techyporcupine/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Util/envs.py", line 252:
        return self.method(*nargs, **kwargs)
      File "/nix/store/0jf6x26nwzgx9d616qiw163d3jgm404k-platformio-6.1.18/lib/python3.13/site-packages/platformio/builder/tools/piobuild.py", line 62:
        env.ProcessProgramDeps()
      File "/home/techyporcupine/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Util/envs.py", line 252:
        return self.method(*nargs, **kwargs)
      File "/nix/store/0jf6x26nwzgx9d616qiw163d3jgm404k-platformio-6.1.18/lib/python3.13/site-packages/platformio/builder/tools/piobuild.py", line 142:
        env.BuildFrameworks(env.get("PIOFRAMEWORK"))
      File "/home/techyporcupine/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Util/envs.py", line 252:
        return self.method(*nargs, **kwargs)
      File "/nix/store/0jf6x26nwzgx9d616qiw163d3jgm404k-platformio-6.1.18/lib/python3.13/site-packages/platformio/builder/tools/piobuild.py", line 352:
        SConscript(env.GetFrameworkScript(name), exports="env")
      File "/home/techyporcupine/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Script/SConscript.py", line 684:
        return method(*args, **kw)
      File "/home/techyporcupine/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Script/SConscript.py", line 620:
        return _SConscript(self.fs, *files, **subst_kw)
      File "/home/techyporcupine/.platformio/packages/tool-scons/scons-local-4.8.1/SCons/Script/SConscript.py", line 280:
        exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
      File "/home/techyporcupine/.platformio/platforms/espressif32/builder/frameworks/espidf.py", line 151:
        assert os.path.isdir(TOOLCHAIN_DIR)
      File "<frozen genericpath>", line 51:
    
  8. aSapien commented on Sep 25, 2025

    @aSapien

    I'm getting the "second run" error from the get go, and consistently:

    ...
    ModuleNotFoundError: No module named 'kconfiglib.core'; 'kconfiglib' is not a package
    CMake Error at /Users/dimar/.platformio/packages/framework-espidf/tools/cmake/kconfig.cmake:209 (message):
    ...
    
  9. ToxicFrog commented on Oct 2, 2025

    @ToxicFrog
    Contributor

    I'm seeing the same thing, and it affects the web UI as well.

    Since some recent ESP32s like the ESP32c6 aren't supported by the arduino platform, this makes them unusable.

  10. nagisa commented on Oct 5, 2025

    @nagisa
    Contributor

    I tried looking for some workaround to get builds going at least temporarily. Here are my findings so far:


    You can get a bit further along by running the following first:

    nix-shell -p esphome platformio platformio-core
    esphome run $yourproject.yaml
    rm -rf ~/.platformio
    pio pkg install -d .esphome/build/$yourproject/
    

    platformio-core seems to be necessary to at least successfully install idf_tools.py. This fails when running plain esphome.

    Despite that pio run -d .esphome/build/$yourproject will still fail with the kconfiglib issue. This seems to be in part at least a kconfiglib (version?) compatibility problem. kconfgen comes alongside with the espidf package (i.e. is taken from ~/.platformio/penv/.espidf-5.4.2/lib/python3.13/site-packages/kconfgen/) whereas the kconfiglib comes from the nix store and although you can import kconfiglib itself, kconfiglib.core is not importable in the plain package.

    >>> import kconfiglib
    >>> import kconfiglib.core
    Traceback (most recent call last):
      File "<python-input-1>", line 1, in <module>
        import kconfiglib.core
    ModuleNotFoundError: No module named 'kconfiglib.core'; 'kconfiglib' is not a package
    

    At least in this aspect this seems more an esphome issue, as it is precisely esphome that pulls in this dep, not platformio.


    Unfortunately it does not look like kconfiglib 14.1.0 is supported even with esp-idf 5.5.1 released recently. That said, upstream seems to have taken note of this and if you set up your project to use the latest esp-idf:

    esp32:
      framework:
        type: esp-idf
        version: latest
        platform_version: 3.3.1
    

    platformio will then attempt to manually reinstall correct version(s) of the python package(s), unconditionally:

    "/nix/store/b58avxjlwyv35kgswgz2gb5hn0v0rsn5-python3-3.13.7-env/bin/python3.13" -m pip install -U --force-reinstall "cryptography>=2.1.4" "future>=0.15.2" "pyparsing>=2.0.3,<2.4.0" "kconfiglib==13.7.1"
    Collecting cryptography>=2.1.4
      Downloading cryptography-46.0.2-cp311-abi3-manylinux_2_34_x86_64.whl.metadata (5.7 kB)
    Collecting future>=0.15.2
      Using cached future-1.0.0-py3-none-any.whl.metadata (4.0 kB)
    Collecting pyparsing<2.4.0,>=2.0.3
      Using cached pyparsing-2.3.1-py2.py3-none-any.whl.metadata (1.0 kB)
    Collecting kconfiglib==13.7.1
      Using cached kconfiglib-13.7.1-py2.py3-none-any.whl.metadata (39 kB)
    Collecting cffi>=2.0.0 (from cryptography>=2.1.4)
      Using cached cffi-2.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.metadata (2.6 kB)
    Collecting pycparser (from cffi>=2.0.0->cryptography>=2.1.4)
      Using cached pycparser-2.23-py3-none-any.whl.metadata (993 bytes)
    Using cached kconfiglib-13.7.1-py2.py3-none-any.whl (145 kB)
    Downloading cryptography-46.0.2-cp311-abi3-manylinux_2_34_x86_64.whl (4.5 MB)
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.5/4.5 MB 36.6 MB/s eta 0:00:00
    Using cached future-1.0.0-py3-none-any.whl (491 kB)
    Using cached pyparsing-2.3.1-py2.py3-none-any.whl (61 kB)
    Using cached cffi-2.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (219 kB)
    Using cached pycparser-2.23-py3-none-any.whl (118 kB)
    Installing collected packages: pyparsing, pycparser, kconfiglib, future, cffi, cryptography
    ERROR: Could not install packages due to an OSError: [Errno 30] Read-only file system: '/nix/store/b58avxjlwyv35kgswgz2gb5hn0v0rsn5-python3-3.13.7-env/lib/python3.13/site-packages/pyparsing.py'
    
    *** Error 1
    

    This unfortunately seems to be impossible to fix with virtual environments either, because this patched /nix/store/b58avxjlwyv35kgswgz2gb5hn0v0rsn5-python3-3.13.7-env/bin/python3.13 overrides the python prefix to /nix/store/b58avxjlwyv35kgswgz2gb5hn0v0rsn5-python3-3.13.7-env.


    The most straightforward fix here would be to downgrade kconfiglib and call it a day. A correct solution, however would be to probably not have esphome+platformio pull python libraries used for project builds from nixpkgs, because versions of those python packages can differ depending on how the project is configured! PlatformIO+esp-idf seems to be quite comfortable with managing its own python prefix in .platformio/penv/.espidf-$VERSION/...

  11. nagisa commented on Oct 5, 2025

    @nagisa
    Contributor

    What works for me is setting up a FHS shell with buildFHSEnv, setting up a venv, installing esphome in it and going from there.

  12. hatch01 commented on Oct 6, 2025

    @hatch01
    Contributor

    This is not very the nix way but just using the esphome container works well :

    virtualisation.oci-containers.containers.esphome = {
          volumes = [ "/persistent/esphome:/config" ];
          environment.TZ = "Europe/Paris";
          image = "ghcr.io/esphome/esphome";
          extraOptions = [
            "--network=host"
          ];
        };
  13. added a commit that references this issue on Nov 13, 2025
    58ff8a7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions