From b8ce2d0ed52ff3319a366d5918ef3b481ab91792 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Mon, 29 Jul 2024 16:16:48 -0500 Subject: [PATCH] Check WSL exists first --- conda_build/build.py | 5 ++++- news/5434-check-for-WSL | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 news/5434-check-for-WSL diff --git a/conda_build/build.py b/conda_build/build.py index 4be112f57b..b5324b988b 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -1738,7 +1738,10 @@ def bundle_conda( if ( # WSL bash is always the same path, it is an alias to the default # distribution as configured by the user - on_win and Path("C:\\Windows\\System32\\bash.exe").samefile(args[0]) + on_win + # check if WSL is installed before calling Path.samefile (which calls os.stat) + and (wsl_bash := Path("C:\\Windows\\System32\\bash.exe")).exists() + and wsl_bash.samefile(args[0]) ): raise CondaBuildUserError( "WSL bash.exe is not supported. Please use MSYS2 packages. Add " diff --git a/news/5434-check-for-WSL b/news/5434-check-for-WSL new file mode 100644 index 0000000000..e063aa3bbe --- /dev/null +++ b/news/5434-check-for-WSL @@ -0,0 +1,19 @@ +### Enhancements + +* + +### Bug fixes + +* Check for WSL existence before calling `os.stat`. (#5433 via #5434) + +### Deprecations + +* + +### Docs + +* + +### Other + +*