From 71cf50e0711fb43808a2b1228a1da242b5f0325e Mon Sep 17 00:00:00 2001 From: Paul Oberosler Date: Mon, 6 Oct 2025 16:22:11 +0100 Subject: [PATCH] scripts: west_commands: fix ZEPHYR_BASE env check detect_version() used os.environ["ZEPHYR_BASE"], which raises a KeyError when the variable is absent, preventing the fallback path from running. Switch to os.environ.get("ZEPHYR_BASE") and use Path(__file__).resolve() for the fallback so the path is absolute/canonical. Signed-off-by: Paul Oberosler --- scripts/west_commands/sdk.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/west_commands/sdk.py b/scripts/west_commands/sdk.py index 149b3bb9be302..e9a57942d5108 100755 --- a/scripts/west_commands/sdk.py +++ b/scripts/west_commands/sdk.py @@ -210,10 +210,11 @@ def detect_version(self, args): if args.version: version = args.version else: - if os.environ["ZEPHYR_BASE"]: - zephyr_base = Path(os.environ["ZEPHYR_BASE"]) + zephyr_base_env = os.environ.get("ZEPHYR_BASE") + if zephyr_base_env: + zephyr_base = Path(zephyr_base_env) else: - zephyr_base = Path(__file__).parents[2] + zephyr_base = Path(__file__).resolve().parents[2] sdk_version_file = zephyr_base / "SDK_VERSION"