Skip to content

Commit cb2c1e5

Browse files
committed
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 <[email protected]>
1 parent 16f4d6c commit cb2c1e5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

scripts/west_commands/sdk.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,11 @@ def detect_version(self, args):
210210
if args.version:
211211
version = args.version
212212
else:
213-
if os.environ["ZEPHYR_BASE"]:
214-
zephyr_base = Path(os.environ["ZEPHYR_BASE"])
213+
zephyr_base_env = os.environ.get("ZEPHYR_BASE")
214+
if zephyr_base_env:
215+
zephyr_base = Path(zephyr_base_env)
215216
else:
216-
zephyr_base = Path(__file__).parents[2]
217+
zephyr_base = Path(__file__).resolve().parents[2]
217218

218219
sdk_version_file = zephyr_base / "SDK_VERSION"
219220

0 commit comments

Comments
 (0)