NCS toolchain path missing in VSCode

I followed the directions/videos to install the nRF development environment for VSCode on a Windows machine: https://www.youtube.com/playlist?list=PLx_tBuQ_KSqEt7NK-H7Lu78lT2OijwIMl

I created the Blinky example and it compiled and ran on the nRF52840 Development Kit.

I then tried to build the peripheral_lbs example and ran into errors.

The path in the VSCode Terminal doesn't include all the paths for the nRF toolchain. This is what I find in VSCode Terminal:

C:\Program Files\Nordic Semiconductor\nrf-command-line-tools\bin\

If I go to Toolchain Manger::nRF Connect SDK v2.10::Open command prompt. This is what I get:

C:\Depot\Source\Library\ncs\toolchains\v2.1.0
C:\Depot\Source\Library\ncs\toolchains\v2.1.0\mingw64\bin
C:\Depot\Source\Library\ncs\toolchains\v2.1.0\bin
C:\Depot\Source\Library\ncs\toolchains\v2.1.0\opt\bin
C:\Depot\Source\Library\ncs\toolchains\v2.1.0\opt\bin\Scripts
C:\Depot\Source\Library\ncs\toolchains\v2.1.0\nanopb\generator-bin
C:\Depot\Source\Library\ncs\toolchains\v2.1.0\opt\zephyr-sdk\arm-zephyr-eabi\bin
Q: How do I fix the nRF Connect VSCode environment to have the same path as that from the Toolchain Manager?
  • Hi, 

    Take a look at this section and set up the Set up the command-line build environment

    Actually, you don't need to install VS Code manually. Toolchain Manager can install automatically. See Installing nRF Connect for VS Code extension

    Regards,
    Amanda

  • Thank you for the quick response but that doesn't address/fix the issue.

    In the "Set up the command-line..." page it says to navigate to the ncs folder and run the zephyr\zephyr-env.cmd script.

    The path is incorrect. There is no zephyr folder in the ncs directory. It is now ncs\<version>\zephyr

    I did run the zephyr-env.cmd in the terminal and it did nothing to the path.

    The zephyr-env.cmd script is:

    @echo off
    set ZEPHYR_BASE=%~dp0

    if exist "%userprofile%\zephyrrc.cmd" (
            call "%userprofile%\zephyrrc.cmd"
    )

    and there is no zephyrrc.cmd file in the %userprofile% directory or anywhere on my computer.

  • Try to remover the VS code and let the Toolchain Manager to install the VS Code. See Installing nRF Connect for VS Code extension

    -Amanda

  • I followed the instructions and I uninstalled VSCode. Ran nRF Connect for Desktop and then Toolchain Manager which told me to install VSCode. I installed VS Code.

    In the Terminal, the path doesn't include the ncs toolchain. I get the same result as my first post.

    The command prompt from Toolchain Manager includes the ncs toolchain path.

    Here is the contents of the OUTPUT tab from VSCode:

    [variant] Loaded new set of variants
    [kit] Successfully loaded 6 kits from C:\Users\HarjitS\AppData\Local\CMakeTools\cmake-tools-kits.json
    [variant] Loaded new set of variants
    [variant] Loaded new set of variants
    [proc] The command: ninja --version failed with error: Error: spawn ninja ENOENT
    [proc] The command: ninja-build --version failed with error: Error: spawn ninja-build ENOENT
    [proc] The command: ninja --version failed with error: Error: spawn ninja ENOENT
    [proc] The command: ninja-build --version failed with error: Error: spawn ninja-build ENOENT
    [proc] Executing command: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -Sc:/Depot/Source/nRF/TestApp/peripheral_lbs -Bc:/Depot/Source/nRF/TestApp/peripheral_lbs/build -G "Unix Makefiles"
    [proc] Executing command: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -Sc:/Depot/Source/nRF/TestApp/myfirstapp -Bc:/Depot/Source/nRF/TestApp/myfirstapp/build -G "Unix Makefiles"
    [proc] The command: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -Sc:/Depot/Source/nRF/TestApp/peripheral_lbs -Bc:/Depot/Source/nRF/TestApp/peripheral_lbs/build -G "Unix Makefiles" exited with code: 1 and signal: null
    [main] Configuring folder: peripheral_lbs
    [proc] The command: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -Sc:/Depot/Source/nRF/TestApp/myfirstapp -Bc:/Depot/Source/nRF/TestApp/myfirstapp/build -G "Unix Makefiles" exited with code: 1 and signal: null
    [main] Configuring folder: myfirstapp
    [proc] Executing command: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -Sc:/Depot/Source/nRF/TestApp/peripheral_lbs -Bc:/Depot/Source/nRF/TestApp/peripheral_lbs/build -G "Unix Makefiles"
    [cmake] Not searching for unused variables given on the command line.
    [cmake] Loading Zephyr default modules (Zephyr base (cached)).
    [cmake] -- Application: C:/Depot/Source/nRF/TestApp/peripheral_lbs
    [proc] Executing command: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=C:\Depot\Source\Library\ncs\toolchains -Sc:/Depot/Source/nRF/TestApp/myfirstapp -Bc:/Depot/Source/nRF/TestApp/myfirstapp/build -G "Unix Makefiles"
    [cmake] -- Using NCS Toolchain 2.1.0 for building. (C:/Depot/Source/Library/ncs/toolchains/v2.1.0/cmake)
    [cmake] Not searching for unused variables given on the command line.
    [cmake] Loading Zephyr default modules (Zephyr base (cached)).
    [cmake] -- Application: C:/Depot/Source/nRF/TestApp/myfirstapp
    [cmake] -- Using NCS Toolchain 2.1.0 for building. (C:/Depot/Source/Library/ncs/toolchains/v2.1.0/cmake)
    [cmake] -- Cache files will be written to: C:/Depot/Source/Library/ncs/v2.1.0/zephyr/.cache
    [cmake] -- Zephyr version: 3.1.99 (C:/Depot/Source/Library/ncs/v2.1.0/zephyr)
    [cmake] -- Cache files will be written to: C:/Depot/Source/Library/ncs/v2.1.0/zephyr/.cache
    [cmake] -- Zephyr version: 3.1.99 (C:/Depot/Source/Library/ncs/v2.1.0/zephyr)
    [cmake] -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    [cmake] -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    [cmake] CMake Error at C:/Depot/Source/Library/ncs/v2.1.0/zephyr/cmake/modules/extensions.cmake:2398 (message):
    [cmake]   BOARD is not being defined on the CMake command-line in the environment or
    [cmake]   by the app.
    [cmake] Call Stack (most recent call first):
    [cmake]   C:/Depot/Source/Library/ncs/v2.1.0/zephyr/cmake/modules/boards.cmake:52 (zephyr_check_cache)
    [cmake]   C:/Depot/Source/Library/ncs/v2.1.0/zephyr/cmake/modules/zephyr_default.cmake:121 (include)
    [cmake]   C:/Depot/Source/Library/ncs/v2.1.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
    [cmake]   C:/Depot/Source/Library/ncs/v2.1.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
    [cmake]   CMakeLists.txt:4 (find_package)
    [cmake]
    [cmake]
    [cmake] -- Configuring incomplete, errors occurred!
    [cmake] See also "C:/Depot/Source/nRF/TestApp/peripheral_lbs/build/CMakeFiles/CMakeOutput.log".
    [cmake] See also "C:/Depot/Source/nRF/TestApp/peripheral_lbs/build/CMakeFiles/CMakeError.log".
    [proc] The command: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -Sc:/Depot/Source/nRF/TestApp/peripheral_lbs -Bc:/Depot/Source/nRF/TestApp/peripheral_lbs/build -G "Unix Makefiles" exited with code: 1 and signal: null
    [cmake] CMake Error at C:/Depot/Source/Library/ncs/v2.1.0/zephyr/cmake/modules/extensions.cmake:2398 (message):
    [cmake]   BOARD is not being defined on the CMake command-line in the environment or
    [cmake]   by the app.
    [cmake] Call Stack (most recent call first):
    [cmake]   C:/Depot/Source/Library/ncs/v2.1.0/zephyr/cmake/modules/boards.cmake:52 (zephyr_check_cache)
    [cmake]   C:/Depot/Source/Library/ncs/v2.1.0/zephyr/cmake/modules/zephyr_default.cmake:121 (include)
    [cmake]   C:/Depot/Source/Library/ncs/v2.1.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
    [cmake]   C:/Depot/Source/Library/ncs/v2.1.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
    [cmake]   CMakeLists.txt:4 (find_package)
    [cmake]
    [cmake]
    [cmake] -- Configuring incomplete, errors occurred!
    [cmake] See also "C:/Depot/Source/nRF/TestApp/myfirstapp/build/CMakeFiles/CMakeOutput.log".
    [cmake] See also "C:/Depot/Source/nRF/TestApp/myfirstapp/build/CMakeFiles/CMakeError.log".
    [proc] The command: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=C:\Depot\Source\Library\ncs\toolchains -Sc:/Depot/Source/nRF/TestApp/myfirstapp -Bc:/Depot/Source/nRF/TestApp/myfirstapp/build -G "Unix Makefiles" exited with code: 1 and signal: null
    [driver] Switching to kit: nRF Zephyr Toolchain
    [proc] The command: ninja --version failed with error: Error: spawn ninja ENOENT
    [proc] The command: ninja-build --version failed with error: Error: spawn ninja-build ENOENT
  • Hi, 

    This looks like the CMake extension. VS Code warns them that the cmake extension isn't compatible with the nordic extension every time it starts up, but you have probably just dismissed or ignored it. They should build using Nordic's extension: https://nrfconnect.github.io/vscode-nrf-connect/connect/build_app_ncs.html

    -Amanda

Related