diff mbox series

tinfoil: show close matches when no providers are found

Message ID 20260220-bitbake-getvar-close-matches-v1-1-c69d9496915b@bootlin.com
State New
Headers show
Series tinfoil: show close matches when no providers are found | expand

Commit Message

Antonin Godard Feb. 20, 2026, 2:30 p.m. UTC
When calling 'bitbake-getvar -r somerecipe FOO', show close matches when
'somerecipe' doesn't exist but close matches are found. This replicates
the behavior of 'bitbake -e'.

Example output:

$ bitbake-getvar -r binutils-cross FOO
Unable to find any recipe file matching "binutils-cross". Close matches:
  binutils-cross-aarch64
  binutils
  util-macros

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
 lib/bb/tinfoil.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)


---
base-commit: d9700632bd6b627d1124fdc83ddf7bfb4199228d
change-id: 20260220-bitbake-getvar-close-matches-cdc2b547546e
diff mbox series

Patch

diff --git a/lib/bb/tinfoil.py b/lib/bb/tinfoil.py
index d9e985c612c..9c1768942ab 100644
--- a/lib/bb/tinfoil.py
+++ b/lib/bb/tinfoil.py
@@ -685,7 +685,14 @@  class Tinfoil:
             if skipreasons:
                 raise bb.providers.NoProvider('%s is unavailable:\n  %s' % (pn, '  \n'.join(skipreasons)))
             else:
-                raise bb.providers.NoProvider('Unable to find any recipe file matching "%s"' % pn)
+                msg = f'Unable to find any recipe file matching "{pn}"'
+                import difflib
+                providers = self.get_all_providers()
+                close_matches = difflib.get_close_matches(pn, providers, cutoff=0.7)
+                if close_matches:
+                    close_matches = "\n  ".join(close_matches)
+                    msg += f'. Close matches:\n  {close_matches}'
+                raise bb.providers.NoProvider(msg)
         return best[3]
 
     def get_file_appends(self, fn, mc=''):