Error compiling esp-matter light_switch example for ESP32-C3: 'ninja: loading build.ninja: No such file or directory'
Posted: Thu Jun 19, 2025 11:41 am
Hello everyone,
As a beginner with Matter development, I am trying to compile the light_switch example from the Espressif esp-matter repository for an ESP32-C3.
Initially, I attempted to compile using VS Code, but I encountered some issues that made me suspect my configuration. Because of this, I switched to compiling directly in the WSL (Ubuntu) terminal, following the installation guides.
The sequence of commands I'm executing in the terminal (starting from the esp-matter root directory and then moving into the example) is as follows:
1- Export the ESP-IDF environment (making sure I'm in the correct ESP-IDF directory):
source ~/esp/esp-idf/export.sh
2 - Navigate to the example directory:
cd ~/espressif/esp-matter/examples/light_switch
3 - Clean the previous build directory (to ensure a clean build):
idf.py fullclean
4 - Set the target chip:
idf.py set-target esp32c3
5 - Attempt to build the project:
idf.py build
The source, cd, fullclean, and set-target commands seem to execute without significant problems or with non-blocking warnings. However, the idf.py build command fails during the compilation step of the chip component, which is part of the Matter SDK (ConnectedHomeIP).
Here is the full error log from the failing part of the build:
[6/1413] Generating ../../partition_table/partition-table.bin
Partition table binary generated. Contents:
... (other log lines not directly related to the main error) ...
[14/1413] Performing build step for 'chip_gn'
FAILED: esp-idf/chip/chip_gn-prefix/src/chip_gn-stamp/chip_gn-build esp-idf/chip/lib/libCHIP.a /home/lincoln/espressif/esp-matter/examples/light_switch/build/esp-idf/chip/chip_gn-prefix/src/chip_gn-stamp/chip_gn-build /home/lincoln/espressif/esp-matter/examples/light_switch/build/esp-idf/chip/lib/libCHIP.a
cd /home/lincoln/espressif/esp-matter/examples/light_switch/build/esp-idf/chip && ninja esp32
ninja: error: loading 'build.ninja': No such file or directory
[17/1413] Performing configure step for 'bootloader'
... (other log lines) ...
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the /home/lincoln/espressif/esp-matter/examples/light_switch/build/log/...
It appears the problem is that the build.ninja file, required to compile the chip component using the ninja build tool, is not being found or generated correctly in the temporary build folder (.../build/esp-idf/chip).
I have already attempted some troubleshooting steps:
I ran idf.py fullclean to clean the build directory.
I ran git submodule deinit -f --all and git submodule update --init --recursive from the root of the esp-matter repository to ensure the connectedhomeip submodule (the Matter SDK) was downloaded and initialized correctly. My esp-matter repository is on the main branch and is confirmed to be up to date (git pull origin main returned "Already up to date").
Despite these attempts, the error persists.
Has anyone in the community encountered this before, or does anyone know what might be causing this 'ninja: error: loading 'build.ninja': No such file or directory' error in this context and how I can resolve it?
Any help or guidance would be greatly appreciated!
Thank you!
Lincoln
As a beginner with Matter development, I am trying to compile the light_switch example from the Espressif esp-matter repository for an ESP32-C3.
Initially, I attempted to compile using VS Code, but I encountered some issues that made me suspect my configuration. Because of this, I switched to compiling directly in the WSL (Ubuntu) terminal, following the installation guides.
The sequence of commands I'm executing in the terminal (starting from the esp-matter root directory and then moving into the example) is as follows:
1- Export the ESP-IDF environment (making sure I'm in the correct ESP-IDF directory):
source ~/esp/esp-idf/export.sh
2 - Navigate to the example directory:
cd ~/espressif/esp-matter/examples/light_switch
3 - Clean the previous build directory (to ensure a clean build):
idf.py fullclean
4 - Set the target chip:
idf.py set-target esp32c3
5 - Attempt to build the project:
idf.py build
The source, cd, fullclean, and set-target commands seem to execute without significant problems or with non-blocking warnings. However, the idf.py build command fails during the compilation step of the chip component, which is part of the Matter SDK (ConnectedHomeIP).
Here is the full error log from the failing part of the build:
[6/1413] Generating ../../partition_table/partition-table.bin
Partition table binary generated. Contents:
... (other log lines not directly related to the main error) ...
[14/1413] Performing build step for 'chip_gn'
FAILED: esp-idf/chip/chip_gn-prefix/src/chip_gn-stamp/chip_gn-build esp-idf/chip/lib/libCHIP.a /home/lincoln/espressif/esp-matter/examples/light_switch/build/esp-idf/chip/chip_gn-prefix/src/chip_gn-stamp/chip_gn-build /home/lincoln/espressif/esp-matter/examples/light_switch/build/esp-idf/chip/lib/libCHIP.a
cd /home/lincoln/espressif/esp-matter/examples/light_switch/build/esp-idf/chip && ninja esp32
ninja: error: loading 'build.ninja': No such file or directory
[17/1413] Performing configure step for 'bootloader'
... (other log lines) ...
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the /home/lincoln/espressif/esp-matter/examples/light_switch/build/log/...
It appears the problem is that the build.ninja file, required to compile the chip component using the ninja build tool, is not being found or generated correctly in the temporary build folder (.../build/esp-idf/chip).
I have already attempted some troubleshooting steps:
I ran idf.py fullclean to clean the build directory.
I ran git submodule deinit -f --all and git submodule update --init --recursive from the root of the esp-matter repository to ensure the connectedhomeip submodule (the Matter SDK) was downloaded and initialized correctly. My esp-matter repository is on the main branch and is confirmed to be up to date (git pull origin main returned "Already up to date").
Despite these attempts, the error persists.
Has anyone in the community encountered this before, or does anyone know what might be causing this 'ninja: error: loading 'build.ninja': No such file or directory' error in this context and how I can resolve it?
Any help or guidance would be greatly appreciated!
Thank you!
Lincoln