Skip to content
Latchkey

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

  1. Run west init and west update so the manifest and Zephyr tree are in place.
  2. Build from inside the workspace so ZEPHYR_BASE is determined automatically.
  3. Re-run the build.
Terminal
west init -m https://github.com/zephyrproject-rtos/zephyr --mr main zephyrproject
cd zephyrproject
west update

Export 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 app

How to prevent it

  • Run west update so the workspace manifest is complete.
  • Build from inside the west topdir.
  • Use the Zephyr setup action, which initializes the workspace.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →