nRF Connect SDK in VS Code is using the wrong CMake (Visual Studio)

Hi,

I upgraded Toolchain and SDK in VS Code to Version 2.6.1.

Now the build is failing.

As far as I can see the wrong CMake will be used - from Visual Studio but it should be Zephyr.

Errors:

[proc] Executing command: "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --version
[proc] Executing command: "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E capabilities
[variant] Loaded new set of variants
[kit] Successfully loaded 4 kits from C:\Users\andre\AppData\Local\CMakeTools\cmake-tools-kits.json
[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: make --version failed with error: Error: spawn make ENOENT
[main] Unable to determine what CMake generator to use. Please install or configure a preferred generator, or update settings.json, your Kit configuration or PATH variable. Error: No usable generator found.
[main] Configuring project: fund_less2_exer2
Could you instruct me how to configure the system in order to use the right CMake?
 
Many thanks in advance
Parents
  • Hi,

    A couple of questions and requests:

    1. Could you generate some support information and add it here? In VS Code press "ctrl + shift + p" to open the command pallette and enter "generate support information" 
    2. Are you using the same source folder that you were using in 2.4.2 in 2.6.1 as well? 
      1. If you have a 2.4.2 project in your workspace in VSCode, the extension may inherit its SDK and/or toolchain version from the workspace rather than what you set it to.
    3. Could you post an image of your nrf connect extension welcome window? 
        
    4. Could you explain how you did the migration from 2.4.2 to 2.6.1 in detail?
    5. I will try to go through the fundamentals course using 2.6.1 just to ensure that everything here is working as it should
    6. Do you also see the same CMake issues if you create a new application from a sample (for instance hello_world)?

    Kind regards,
    Andreas

  • 1. Support Information looks like this:

    [09:52:07] Invalid application location: 'd:\ncs-fund\hello world'
    [09:52:10] nRF Command Line Tools 10.24.2 are up to date
    IMPORTANT: The data below could contain sensitive or confidential information about your environment.
    If you do not wish this to be seen by others, please make sure to remove it before sharing.

    For help and support, visit the Nordic DevZone at devzone.nordicsemi.com/.

    {
      "platform": {
        "os": "win32",
        "osVersion": "Windows 10 Pro",
        "osKernel": "10.0.19045",
        "vscode": "1.90.0",
        "electron": "29.4.0",
        "node": "v20.9.0"
      },
      "system": {
        "date": "2024-06-12T07:52:59.159Z",
        "vscodeRoot": "c:\\Users\\andre\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app",
        "nrfConnectForDesktopInstalled": true,
        "vscodeUptime": "00:01:04",
        "osUptime": "212:44:32",
        "cpu": "Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz"
      },
      "workspace": {
        "name": "hello world",
        "workspaceFile": null,
        "folders": [
          "d:\\ncs-fund\\hello world"
        ]
      },
      "sdks": [
        {
          "version": "v2.6.1",
          "path": "c:\\ncs\\v2.6.1"
        }
      ],
      "apps": [],
      "topdir": "c:\\ncs\\v2.6.1",
      "workspaceState": "freestanding-ready",
      "toolchains": [
        {
          "version": "2.6.1",
          "path": "c:\\ncs\\toolchains\\cf2149caf2"
        }
      ],
      "connectedDevices": [],
      "deviceProvider": "nrfutil",
      "tools": {
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin\\arm-zephyr-eabi-gcc.exe": "0.16.5",
        "C:\\Program Files\\SEGGER\\JLink_V796g\\JLink.exe": "7.96g",
        "C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\nrfjprog.exe": "10.24.2",
        "C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\nrfutil.exe": "7.7.1",
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\cmake.exe": "3.21.0",
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\Scripts\\west.exe": "1.2.0",
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\python.exe": "3.9.13",
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\ninja.exe": "1.10.2",
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\gperf.exe": "3.1",
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\dtc.exe": "1.4.7",
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\gn.exe": "2154",
        "C:\\ncs\\toolchains\\cf2149caf2\\mingw64\\bin\\git.exe": "2.37.3.windows.1",
        "gdbPath": "c:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin\\arm-zephyr-eabi-gdb.exe"
      },
      "nrfutil": {
        "nrfutil-device": {
          "version": "2.0.0",
          "binPath": "c:\\Users\\andre\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2024.3.25-win32-x64\\platform\\nrfutil\\bin\\nrfutil-device"
        },
        "nrfutil-toolchain-manager": {
          "version": "0.14.1",
          "binPath": "c:\\Users\\andre\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2024.3.25-win32-x64\\platform\\nrfutil\\bin\\nrfutil-toolchain-manager"
        }
      },
      "environment": {
        "westEnv": {
          "ELECTRON_RUN_AS_NODE": "1",
          "HOME": "C:\\Users\\andre",
          "HOMEDRIVE": "C:",
          "HOMEPATH": "\\Users\\andre",
          "PATH": "C:\\ncs\\toolchains\\cf2149caf2;C:\\ncs\\toolchains\\cf2149caf2\\mingw64\\bin;C:\\ncs\\toolchains\\cf2149caf2\\bin;C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin;C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\Scripts;C:\\ncs\\toolchains\\cf2149caf2\\opt\\nanopb\\generator-bin;C:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk\\aarch64-zephyr-elf\\bin;C:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk\\x86_64-zephyr-elf\\bin;C:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin;C:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk\\riscv64-zephyr-elf\\bin;c:\\Users\\andre\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2024.3.25-win32-x64\\platform\\nrfutil\\lib\\nrfutil-toolchain-manager;C:\\Program Files\\Microsoft\\jdk-11.0.16.101-hotspot\\bin;C:\\Python311\\Scripts\\;C:\\Python311\\;C:\\Program Files\\Eclipse Foundation\\jdk-8.0.302.8-hotspot\\bin;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\150\\DTS\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\150\\DTS\\Binn\\;C:\\Program Files\\Azure Data Studio\\bin;C:\\Program Files\\TortoiseGit\\bin;C:\\Program Files\\dotnet\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Docker\\Docker\\resources\\bin;C:\\Program Files\\PuTTY\\;C:\\Program Files\\nodejs\\;C:\\ProgramData\\chocolatey\\bin;C:\\Users\\andre\\AppData\\Roaming\\npm;C:\\Program Files (x86)\\curl\\bin;C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\;C:\\Program Files\\SEGGER\\JLink_V794e;C:\\Users\\andre\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\andre\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Program Files\\Azure Data Studio\\bin;C:\\Users\\andre\\.dotnet\\tools;C:\\Users\\andre\\AppData\\Roaming\\npm;C:\\Program Files\\JetBrains\\WebStorm 2022.3.2\\bin;",
          "ZEPHYR_BASE": "c:\\ncs\\v2.6.1\\zephyr",
          "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
          "ZEPHYR_SDK_INSTALL_DIR": "C:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk",
          "PYTHONPATH": "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin;C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\Lib;C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\Lib\\site-packages"
        },
        "inherited": {
          "ELECTRON_RUN_AS_NODE": "1",
          "HOME": "C:\\Users\\andre",
          "HOMEDRIVE": "C:",
          "HOMEPATH": "\\Users\\andre",
          "Path": "C:\\Program Files\\Microsoft\\jdk-11.0.16.101-hotspot\\bin;C:\\Python311\\Scripts\\;C:\\Python311\\;C:\\Program Files\\Eclipse Foundation\\jdk-8.0.302.8-hotspot\\bin;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\150\\DTS\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\150\\DTS\\Binn\\;C:\\Program Files\\Azure Data Studio\\bin;C:\\Program Files\\TortoiseGit\\bin;C:\\Program Files\\dotnet\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Docker\\Docker\\resources\\bin;C:\\Program Files\\PuTTY\\;C:\\Program Files\\nodejs\\;C:\\ProgramData\\chocolatey\\bin;C:\\Users\\andre\\AppData\\Roaming\\npm;C:\\Program Files (x86)\\curl\\bin;C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\;C:\\Program Files\\SEGGER\\JLink_V794e;C:\\Users\\andre\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\andre\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Program Files\\Azure Data Studio\\bin;C:\\Users\\andre\\.dotnet\\tools;C:\\Users\\andre\\AppData\\Roaming\\npm;C:\\Program Files\\JetBrains\\WebStorm 2022.3.2\\bin;",
          "PATH": "C:\\Program Files\\Microsoft\\jdk-11.0.16.101-hotspot\\bin;C:\\Python311\\Scripts\\;C:\\Python311\\;C:\\Program Files\\Eclipse Foundation\\jdk-8.0.302.8-hotspot\\bin;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\150\\DTS\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\150\\DTS\\Binn\\;C:\\Program Files\\Azure Data Studio\\bin;C:\\Program Files\\TortoiseGit\\bin;C:\\Program Files\\dotnet\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Docker\\Docker\\resources\\bin;C:\\Program Files\\PuTTY\\;C:\\Program Files\\nodejs\\;C:\\ProgramData\\chocolatey\\bin;C:\\Users\\andre\\AppData\\Roaming\\npm;C:\\Program Files (x86)\\curl\\bin;C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\;C:\\Program Files\\SEGGER\\JLink_V794e;C:\\Users\\andre\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\andre\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Program Files\\Azure Data Studio\\bin;C:\\Users\\andre\\.dotnet\\tools;C:\\Users\\andre\\AppData\\Roaming\\npm;C:\\Program Files\\JetBrains\\WebStorm 2022.3.2\\bin;",
          "ZEPHYR_BASE": "C:\\ncs\\v2.6.1\\zephyr"
        },
        "toolchainPath": "c:\\ncs\\toolchains\\cf2149caf2",
        "toolchainBinPath": "c:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin",
        "toolchainVersion": "2.6.1"
      },
      "terminal": {
        "defaultProfile": null
      },
      "config": {
        "nordic-semiconductor.nrf-connect": {
          "topdir": "${nrf-connect.sdk:2.6.0}",
          "toolchain": {
            "path": "${nrf-connect.toolchain:2.6.1}"
          },
          "ozonePath": "",
          "applications": [],
          "applicationOptions": {},
          "kconfig": {
            "interface": "kconfig"
          },
          "west": {
            "env": {
              "$base": "terminal"
            }
          },
          "boardRoots": [],
          "taskBindings": {},
          "buildTerminal": {
            "condensedProgress": true
          },
          "debugging": {
            "flash": true,
            "bindings": {},
            "justMyCode": true
          },
          "activeAppFollowActiveEditor": true,
          "deviceProvider": "",
          "flash": {
            "softreset": false,
            "erase": false,
            "recover": false
          },
          "enableTelemetry": true,
          "thirdpartyIntegration": {},
          "toolchainManager": {
            "indexURL": null,
            "installDirectory": null
          },
          "nrfutil": {
            "home": null
          },
          "defaultOpenAction": "ask"
        },
        "nordic-semiconductor.nrf-terminal": {
          "terminalMode": "character"
        }
      },
      "extensions": {
        "internal": {
          "nordic-semiconductor.nrf-connect": {
            "version": "2024.3.25",
            "path": "c:\\Users\\andre\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2024.3.25-win32-x64",
            "isActive": true
          },
          "nordic-semiconductor.nrf-terminal": {
            "version": "2024.3.15",
            "path": "c:\\Users\\andre\\.vscode\\extensions\\nordic-semiconductor.nrf-terminal-2024.3.15",
            "isActive": true
          },
          "nordic-semiconductor.nrf-devicetree": {
            "version": "2024.3.78",
            "path": "c:\\Users\\andre\\.vscode\\extensions\\nordic-semiconductor.nrf-devicetree-2024.3.78",
            "isActive": true
          },
          "nordic-semiconductor.nrf-kconfig": {
            "version": "2024.3.21",
            "path": "c:\\Users\\andre\\.vscode\\extensions\\nordic-semiconductor.nrf-kconfig-2024.3.21",
            "isActive": true
          }
        },
        "external": {
          "marus25.cortex-debug": null,
          "ms-vscode.cpptools": "1.20.5",
          "ms-vscode.js-debug": "1.90.0",
          "ms-vscode.js-debug-companion": "1.1.2",
          "ms-vscode.vscode-js-profile-table": "1.0.9",
          "Angular.ng-template": "18.0.0",
          "esbenp.prettier-vscode": "10.4.0",
          "jakethashi.vscode-angular2-emmet": "2.0.3",
          "jebbs.plantuml": "2.18.1",
          "ms-azuretools.vscode-docker": "1.29.1",
          "MS-CEINTL.vscode-language-pack-de": "1.89.2024050109",
          "ms-vscode-remote.remote-containers": "0.369.0",
          "ms-vscode-remote.remote-wsl": "0.88.2",
          "ms-vscode.cmake-tools": "1.18.42",
          "ms-vscode.cpptools-extension-pack": "1.3.0",
          "ms-vscode.cpptools-themes": "2.0.0",
          "pierre3.csharp-to-plantuml": "1.4.0",
          "trond-snekvik.gnu-mapfiles": "1.1.0",
          "twxs.cmake": "0.0.17"
        }
      }
    }

    2. Created a new project from the scratch for this analysis. VS Code still goes:
    [proc] Executing command: "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --version
    [proc] Executing command: "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E capabilities
    [variant] Loaded new set of variants
    [kit] Successfully loaded 4 kits from C:\Users\andre\AppData\Local\CMakeTools\cmake-tools-kits.json
    [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: make --version failed with error: Error: spawn make ENOENT
    [main] Unable to determine what CMake generator to use. Please install or configure a preferred generator, or update settings.json, your Kit configuration or PATH variable. Error: No usable generator found.
    [main] Configuring project: hello world
    3. nRF Connect Welcome Window
    4. Migration
    Installed latest toolchain, switched to latest toolchain
    Installed latest SDK, switched to latest SDK
    Uninstalled old toolchain
    Uninstalled old SDK
    6. Yes
    Same goes for the brand new Hello Word app
    What I am observing is that the inital build after adding a build configuration works but all later builds after making changes result in the CMake-Errors above. In addition to that the following error popup comes up in VS Code: Unable to determine what CMake generator to use. Please install or configure a preferred generator, or update settings.json, your Kit configuration or PATH variable.
    I guess you need a least Visual Studio installation in order to reproduce the issue.
  • Andreas Schurz said:
    1. Support Information looks like this:

    One potential noteworthy difference between mine and your setup is the addition of  "ms-vscode.cmake-tools": "1.18.42", under the "external: {}" part of the support information.

    Another is that I have C:\\Program Files\\CMake\\bin in path under "environment" and "inherited".

    I don't think that this necessarily is the root cause of the issue, but it could be worth looking into if the ms-vscode.cmake-tools you have overwrites whatever the SDK should use. 

    Andreas Schurz said:
    2. Created a new project from the scratch for this analysis. VS Code still goes:

    Noted, thank you for verifying

    Andreas Schurz said:
    3. nRF Connect Welcome Window

    All looks good to me

    Andreas Schurz said:
    4. Migration

    This looks sane.

    Andreas Schurz said:
    What I am observing is that the inital build after adding a build configuration works but all later builds after making changes result in the CMake-Errors above.

    Interesting. Does this also occur if you build a clean hello_world, remove the build folder and then re-build with changes to the code?

    Some other suggestions from are: docs.nordicsemi.com/.../index.html

    1. Configure the generator in your system's PATH variable. This involves adding the directory containing the generator's executable to your system's PATH.
    2. Update your settings.json file or your Kit configuration to specify the preferred generator (ninja for windows)

    If you're using the Zephyr build system, the default build tool is west, which invokes cmake and the underlying build tool (ninja or make) behind the scenes so everything should be set up properly from the installers side given that you don't have any conflicting instances of cmake with higher use priority set up in your VSCode installation/in your system variable Path

    And the final suggestion, which might save some debugging time, is to see if the issue is present after either a clean install of VS Code, the extension and the tools on your current computer or to see if the process is reproducable on another computer if you have one available. Atleast a new install of NCS resolved this other users issue with the fault: source

    Kind regards,
    Andreas

  • Regarding the paths:

    1. Configure the generator in your system's PATH variable. This involves adding the directory containing the generator's executable to your system's PATH.
    2. Update your settings.json file or your Kit configuration to specify the preferred generator (ninja for windows)

    I am a little bit lost. I haven't found the information on the page: docs.nordicsemi.com/.../index.html

    Could you supply an example where the generator executable is actually located?

    My root dir is simply C:\ncs

    Here? C:\ncs\v2.6.1\zephyr\cmake or where?

    Where is settings.json and how to update it?

    Regarding the failed build:

    Interesting. Does this also occur if you build a clean hello_world, remove the build folder and then re-build with changes to the code?

    This works. But only one time. I have to remove the build config and add again for every build. Builds then but CMake error also comes up. When I do an incremental build CMake error comes up and build fails.

    And the final suggestion, which might save some debugging time, is to see if the issue is present after either a clean install of VS Code, the extension and the tools on your current computer or to see if the process is reproducable on another computer if you have one available. Atleast a new install of NCS resolved this other users issue with the fault: source

    I can do a clean install + update on a dedicated devopment VM which I have to do anyway for documentation purposes next week.

  • AHaug said:
    One potential noteworthy difference between mine and your setup is the addition of  "ms-vscode.cmake-tools": "1.18.42", under the "external: {}" part of the support information.

    While looking around I found that this might be the rootcause. Could you check your VS Code extensions and see if the microsoft cmake tools is conflicting with what is installed through the SDK installer? Another user suggested that this extension could cause conflicts for other things, but it might also cause the conflict that you're seeing

    Andreas Schurz said:

    I am a little bit lost. I haven't found the information on the page: docs.nordicsemi.com/.../index.html

    Could you supply an example where the generator executable is actually located?

    No worries,

    To my understanding it is here:

    Before making any changes, could you check if there are any conflicting versions here?

    And could you check your systems environmental path items to see if there are any confliciting cmake instances there?

    Andreas Schurz said:
    I can do a clean install + update on a dedicated devopment VM which I have to do anyway for documentation purposes next week.

    Noted, if the removal of the ms cmake extension does not resolve it, then there could be something that has gone wrong through the installation procedure.

    Kind regards,
    Andreas

  • Ok. That's the issue.

    Trick is to disable VS Code CMake build extensions.

    1. Open VS Code Extensions via Ctrl + Shift X

    2. Disable the following extensions

    Now everything works as expected.

    Regards, Andreas

Reply Children
Related