zephyr: ninja: error: loading 'build.ninja': No such file or directory

If a pristine build fails during CMake configure, it leaves a build folder that breaks incremental building. The telltale log message is ninja: error: loading 'build.ninja': No such file or directory. This problem does not appear in vanilla non-Zephyr CMake.

To Reproduce Steps to reproduce the behavior:

  • Start with the hello world sample.
  • Make sure there is no build folder yet.
  • Add some error to CMakeLists.txt. E.g. append this_is_not_defined().
  • Run west build -b native_posix. (Selected board is irrelevant.)
  • Observe CMake error.
  • Fix error in CMakeLists.txt.
  • Run west build for incremental build.
  • Observe bug ninja: error: loading 'build.ninja': No such file or directory.

The workaround is to delete the build folder.

Impact User confusion, major annoyance.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 17 (14 by maintainers)

Most upvoted comments

I did not say it was a west issue. I added the “area: Build System” label. @thedjnK changed it to “area: West”. This is a DX issue that should be addressed, so I’ll reopen this.

I still think it’s a west build failure. If it was really a “convenient wrapper” it would:

  • if there’s a build.ninja just run ninja build
  • if there is no build.ninja, do a cmake run before

Doesn’t seem like rocket science to me, and would solve this UX issue.

and just to make it clear, from west help build:

$ west help build
usage: west build ....

Convenience wrapper for building Zephyr applications.

...
cmake and build tool:
  -c, --cmake           force a cmake run
...