Skip to content

west build: display closest matches when an invalid board is given #91110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pillo79
Copy link
Contributor

@pillo79 pillo79 commented Jun 5, 2025

Currently, when an invalid board name is given to west build, it prints the full set of available boards, which is a wall of text that gives no immediate help to the user.

This PR modifies this behavior so that when an invalid board is specified, the 3 board names that most closely match the input are printed. The user is also instructed to get the full set of boards via west boards:

$ west build -p -b ardduino_giga_r1/stm32h747xx/m7 samples/hello_world
-- west build: making build dir pristine
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: samples/hello_world
-- CMake version: 3.22.1
-- Found Python3: venv/bin/python3.12 (found suitable version "3.12.0", minimum required is "3.10") found components: Interpreter 
-- Cache files will be written to: ~/.cache/zephyr
-- Zephyr version: 4.1.99 (zephyr)
-- Found west (found suitable version "1.4.0", minimum required is "0.14.0")
No board named 'ardduino_giga_r1' found. Did you mean:

arduino_giga_r1
arduino_uno_r4
arduino_zero

Run 'west boards' for the full list.
CMake Error at zephyr/cmake/modules/boards.cmake:225 (message):
  Invalid BOARD; see above.

@pdgendt
Copy link
Contributor

pdgendt commented Jun 5, 2025

FYI #89483

Copy link

sonarqubecloud bot commented Jun 5, 2025

@pillo79
Copy link
Contributor Author

pillo79 commented Jun 5, 2025

FYI #89483

Thanks, didn't notice that. Compared to the above, this PR has no side effects as it only affects the actual error path via the new command line argument.

(In fact, I did fully implement custom sorting in west boards... before realizing the error path directly calls the list_boards.py Python script. That same file is imported as a module by west boards to reuse some internal functions, but not the arg parsing / output code, so we can't immediately use the same logic in both places.)

@pillo79 pillo79 marked this pull request as ready for review June 5, 2025 12:50
@tejlmand
Copy link
Contributor

I placed a comment here: #89483 (comment)

Regarding sorting for builds, then board name sorting could make more sense, but if really expected to help users, then it's seems to be assumed that at least first letters was correctly typed.

Boards is a growing list in Zephyr, which is a good thing, but makes printing all boards on invalid boards hard to use.

Users often know the vendor of their board, even if they typed the name itself wrong, so I wonder if doing format printing where the vendor is also printed would help users more when trying to find the correct board.

For example we could have something like:

No board named 'nfr53' found.

Please choose one of the following boards:

01space,esp32c3_042_oled
ti,cc3235sf_launchxl
...
ti,sk_am64
ti,sk_am62
ti,lp_em_cc2340r5
...
luatos,esp32c3_luatos_core
luatos,esp32s3_luatos_core
circuitdojo,circuitdojo_feather
heltec,heltec_wifi_lora32_v2
heltec,heltec_wireless_stick_lite_v3
...

or perhaps:

Vendor: 01space, board: esp32c3_042_oled
Vendor: ti, board: cc3235sf_launchxl
...

I do agree we need to improve, but not sure just order alphabetically will solve our problems.
Might make some parts cleaner, but not all.

@pillo79 pillo79 changed the title west build: display sorted list of boards on error west build: display closest matches when an invalid board is given Jul 8, 2025
@pillo79 pillo79 force-pushed the pr-west-sort-boards branch from 40c5330 to 59b9837 Compare July 8, 2025 08:51
This commit modifies the 'west build' command to display the closest
matching boards when an invalid board is specified, making it easier
for users to find a typo in the used board name.

The user is also instructed to run 'west boards' if he wants to get
the full list of available boards.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
@pillo79 pillo79 force-pushed the pr-west-sort-boards branch from 59b9837 to 77950d9 Compare July 8, 2025 08:53
Copy link

sonarqubecloud bot commented Jul 8, 2025

Please retry analysis of this Pull-Request directly on SonarQube Cloud

@pillo79
Copy link
Contributor Author

pillo79 commented Jul 8, 2025

@rruuaanng @pdgendt @tejlmand

v2, review ready: instead of printing the whole table of supported boards on error, only print a few close matches to the requested one.

This replaces the wall of text with actionable options in case of a minimal typo. The user is also instructed to use west boards for the full list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants