Cannot find Zephyr-sdkConfig.cmake

I picked up a project that was last worked on several months ago, updated all the tools, and can't get past this:

[18:25] jwr-macbook-pro:/opt/nordic/ncs/v2.1.0/nrf/samples/peripheral/lpuart>west build -b nrf52840_mdk
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base (cached)).
-- Application: /opt/nordic/ncs/v2.1.0/nrf/samples/peripheral/lpuart
-- Using NCS Toolchain 2.1.0 for building. (/opt/nordic/ncs/toolchains/v2.1.0/cmake)
-- Cache files will be written to: /Users/jwr/Library/Caches/zephyr
-- Zephyr version: 3.1.99 (/opt/nordic/ncs/v2.1.0/zephyr)
-- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
-- Board: nrf52840_mdk
CMake Error at /opt/nordic/ncs/v2.1.0/zephyr/cmake/modules/verify-toolchain.cmake:84 (find_package):
  Could not find a package configuration file provided by "Zephyr-sdk"
  (requested version 0.13.1) with any of the following names:

    Zephyr-sdkConfig.cmake
    zephyr-sdk-config.cmake

  Add the installation prefix of "Zephyr-sdk" to CMAKE_PREFIX_PATH or set
  "Zephyr-sdk_DIR" to a directory containing one of the above files.  If
  "Zephyr-sdk" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  /opt/nordic/ncs/v2.1.0/zephyr/cmake/modules/zephyr_default.cmake:121 (include)
  /opt/nordic/ncs/v2.1.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  /opt/nordic/ncs/v2.1.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
  CMakeLists.txt:9 (find_package)


-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: /opt/homebrew/bin/cmake -DWEST_PYTHON=/opt/homebrew/opt/[email protected]/bin/python3.10 -B/opt/nordic/ncs/v2.1.0/nrf/samples/peripheral/lpuart/build -GNinja -S/opt/nordic/ncs/v2.1.0/nrf/samples/peripheral/lpuart

I normally use my own checkout of nRF Connect SDK, but this time I even tried using the SDK installed with the toolchain (see above), same results.

I have no idea why this started happening, I never had to point to Zephyr-sdkConfig.cmake. A file with that name does exist in /opt/nordic/ncs/toolchains/v2.1.0/opt/zephyr-sdk/cmake/Zephyr-sdkConfig.cmake, but I have no idea why west is unable to find it.

I have ZEPHYR_BASE=/opt/nordic/ncs/v2.1.0/zephyr and ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb and GNUARMEMB_TOOLCHAIN_PATH=/opt/nordic/ncs/toolchains/v2.1.0.

This is on an Apple Silicon (M1) Mac under Mac OS 12.6.

Any pointers would be appreciated, as I'm completely stuck on this unexpected problem!

  • So I launched nRF Connect for Desktop, which upgraded itself to v3.12.1, which seems to be the newest released version. I then launched Toolchain Manager 1.1.3 from within it. I used "Open Terminal", cd'd to the sample directory and I get the same thing:

    [17:34] jwr-macbook-pro:/opt/nordic/ncs/v2.1.0/nrf/samples/peripheral/lpuart>west build -b nrf52840dk_nrf52840 --pristine
    -- west build: making build dir /opt/nordic/ncs/v2.1.0/nrf/samples/peripheral/lpuart/build pristine
    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: /opt/nordic/ncs/v2.1.0/nrf/samples/peripheral/lpuart
    -- Using NCS Toolchain 2.1.0 for building. (/opt/nordic/ncs/toolchains/v2.1.0/cmake)
    -- Found Python3: /opt/nordic/ncs/toolchains/v2.1.0/bin/python3 (found suitable exact version "3.9.6") found components: Interpreter
    -- Cache files will be written to: /Users/jwr/Library/Caches/zephyr
    -- Zephyr version: 3.1.99 (/opt/nordic/ncs/v2.1.0/zephyr)
    -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    -- Board: nrf52840dk_nrf52840
    CMake Error at /opt/nordic/ncs/v2.1.0/zephyr/cmake/modules/verify-toolchain.cmake:84 (find_package):
    Could not find a package configuration file provided by "Zephyr-sdk"
    (requested version 0.13.1) with any of the following names:

    Zephyr-sdkConfig.cmake
    zephyr-sdk-config.cmake

    Add the installation prefix of "Zephyr-sdk" to CMAKE_PREFIX_PATH or set
    "Zephyr-sdk_DIR" to a directory containing one of the above files. If
    "Zephyr-sdk" provides a separate development package or SDK, be sure it has
    been installed.
    Call Stack (most recent call first):
    /opt/nordic/ncs/v2.1.0/zephyr/cmake/modules/zephyr_default.cmake:121 (include)
    /opt/nordic/ncs/v2.1.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
    /opt/nordic/ncs/v2.1.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
    CMakeLists.txt:9 (find_package)


    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: /opt/homebrew/bin/cmake -DWEST_PYTHON=/opt/homebrew/opt/[email protected]/bin/python3.10 -B/opt/nordic/ncs/v2.1.0/nrf/samples/peripheral/lpuart/build -GNinja -DBOARD=nrf52840dk_nrf52840 -S/opt/nordic/ncs/v2.1.0/nrf/samples/peripheral/lpuart
    [17:38] jwr-macbook-pro:/opt/nordic/ncs/v2.1.0/nrf/samples/peripheral/lpuart>

  • I am not able to reproduce, but looking et the errors there seems to still be problems with the environment variables. You can verify this by echoing the relevant environment variables and checking with what value they should have by lookin in /opt/nordic/ncs/toolchains/v2.1.0/environment.json which lists all variables and their content (this is what is used by the toolchain manager when opening a terminal).

    As these are set by the toolchain manager I suspect you change some of them after opening the terminal via the Toolchain manager (deliberately or not)?

  • Ok, so this took a while, but I did figure this out. The short answer is that what was missing in my environment was a variable called "ZEPHYR_SDK_INSTALL_DIR" which needs to be set to "/opt/nordic/ncs/toolchains/v2.1.0/opt/zephyr-sdk".

    What seems to be a clear bug in the Toolchain Manager is that this variable DOES NOT get set if the user's shell is "/bin/tcsh". I suspect it was only tested with "/bin/bash" and assumes that this is the shell that everyone uses.

    I would also suggest that is is perhaps worth checking why this crucial variable isn't mentioned in the documentation much. I checked:

    none of these contain the string "ZEPHYR_SDK_INSTALL_DIR", which I think is a problem. I am not sure how I am supposed to discover that this variable needs to be set and what it should be set to.

  • Hi Jan,

    Thanks for letting me know! The toolchain manager is tested with zsh, which is the default shell in recent macOS versions, but not other shells. I have forwarded your comments about the missing documentation about ZEPHYR_SDK_INSTALL_DIR so that it can be added for a future release.

Related