Zephyr "ZEPHYR_BASE" not set in CI
Zephyr's build system locates the kernel tree through ZEPHYR_BASE. When west or CMake cannot find it set, it cannot resolve the Zephyr sources and the build stops before configuration completes.
What this error means
A west build or CMake step fails with "ZEPHYR_BASE is not set" or a fatal error that the Zephyr base directory could not be found.
west
CMake Error at cmake/modules/zephyr_default.cmake:
ZEPHYR_BASE was not set and could not be determined from the west workspace.Common causes
The workspace environment was not initialized
west needs an initialized workspace (west init plus west update) so it can determine ZEPHYR_BASE from the manifest.
Building outside the west workspace
Running the build from a directory not under the west topdir means ZEPHYR_BASE cannot be inferred and is not exported.
How to fix it
Initialize the workspace then build
- Run
west initandwest updateso the manifest and Zephyr tree are in place. - Build from inside the workspace so ZEPHYR_BASE is determined automatically.
- Re-run the build.
Terminal
west init -m https://github.com/zephyrproject-rtos/zephyr --mr main zephyrproject
cd zephyrproject
west updateExport ZEPHYR_BASE explicitly if needed
When building outside the topdir, point ZEPHYR_BASE at the Zephyr checkout.
.github/workflows/ci.yml
export ZEPHYR_BASE=${{ github.workspace }}/zephyrproject/zephyr
west build -b qemu_x86 appHow to prevent it
- Run
west updateso the workspace manifest is complete. - Build from inside the west topdir.
- Use the Zephyr setup action, which initializes the workspace.
Related guides
Zephyr "west: command not found" in CIFix Zephyr "west: command not found" in CI - the west meta-tool was never pip installed, or its install locat…
Zephyr CMake "BOARD is not defined" in CIFix Zephyr "CMake Error: BOARD is not defined" in CI - west build was invoked without a target board, so CMak…
Zephyr devicetree error in CIFix Zephyr "devicetree error" in CI - an overlay or node reference is invalid, so the devicetree compiler rej…