Skip to content

Commit 4240f4b

Browse files
committed
Improve error messages when the WASI SDK can't be found
1 parent f5c7535 commit 4240f4b

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

Platforms/WASI/_build.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,8 @@ def wasi_sdk(context):
221221
"""Find the path to the WASI SDK."""
222222
if wasi_sdk_path := context.wasi_sdk_path:
223223
if not wasi_sdk_path.exists():
224-
raise ValueError(
225-
"WASI SDK not found; "
226-
"download from "
227-
"https://github.com/WebAssembly/wasi-sdk and/or "
228-
"specify via $WASI_SDK_PATH or --wasi-sdk"
229-
)
224+
raise ValueError("WASI SDK not found at "
225+
f"{os.fsdecode(wasi_sdk_path)!r} (via --wasi-sdk)")
230226
return wasi_sdk_path
231227

232228
with (HERE / "config.toml").open("rb") as file:
@@ -237,7 +233,8 @@ def wasi_sdk(context):
237233
wasi_sdk_path = pathlib.Path(wasi_sdk_path_env_var)
238234
if not wasi_sdk_path.exists():
239235
raise ValueError(
240-
f"WASI SDK not found at $WASI_SDK_PATH ({wasi_sdk_path})"
236+
f"WASI SDK not found at {os.fsdecode(wasi_sdk_path)!r} "
237+
"(via $WASI_SDK_PATH)"
241238
)
242239
else:
243240
opt_path = pathlib.Path("/opt")
@@ -272,6 +269,14 @@ def wasi_sdk(context):
272269
f" Found WASI SDK {major_version}, "
273270
f"but WASI SDK {wasi_sdk_version} is the supported version",
274271
)
272+
elif not wasi_sdk_path:
273+
raise ValueError(
274+
f"WASI SDK {wasi_sdk_version} not found; "
275+
"download from "
276+
"https://github.com/WebAssembly/wasi-sdk and install in "
277+
f"{os.fsdecode(opt_path)!r} or specify the SDK via "
278+
"$WASI_SDK_PATH or --wasi-sdk"
279+
)
275280

276281
# Cache the result.
277282
context.wasi_sdk_path = wasi_sdk_path

0 commit comments

Comments
 (0)