From d33bf29823624e31ee1ced878dab43058c716a1d Mon Sep 17 00:00:00 2001 From: ahochheiden Date: Fri, 14 Jul 2023 21:27:58 +0000 Subject: [PATCH] Bug 1842691 - Check for spaces in `topsrcdir` and `MOZILLABUILD` (on Windows) on Mach startup r=firefox-build-system-reviewers,glandium We've had this restriction for a while (with a note of it in the docs, but the note in the docs can easily be overlooked, leading to confusing errors). Erroring out right on Mach startup and providing instructions for the workaround immediately should help users get around this issue faster. Differential Revision: https://phabricator.services.mozilla.com/D183209 --- build/mach_initialize.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/build/mach_initialize.py b/build/mach_initialize.py index e28068800966..b142247983ce 100644 --- a/build/mach_initialize.py +++ b/build/mach_initialize.py @@ -119,6 +119,24 @@ def _maybe_activate_mozillabuild_environment(): os.environ["PATH"] += f"{os.pathsep}{new_path}" +def check_for_spaces(topsrcdir): + if " " in topsrcdir: + raise Exception( + f"Your checkout at path '{topsrcdir}' contains a space, which " + f"is not supported. Please move it to somewhere that does not " + f"have a space in the path before rerunning mach." + ) + + mozillabuild_dir = os.environ.get("MOZILLABUILD", "") + if sys.platform == "win32" and " " in mozillabuild_dir: + raise Exception( + f"Your installation of MozillaBuild appears to be installed on a path that " + f"contains a space ('{mozillabuild_dir}') which is not supported. Please " + f"reinstall MozillaBuild on a path without a space and restart your shell" + f"from the new installation." + ) + + def initialize(topsrcdir): # This directory was deleted in bug 1666345, but there may be some ignored # files here. We can safely just delete it for the user so they don't have @@ -143,6 +161,8 @@ def initialize(topsrcdir): state_dir = _create_state_dir() + check_for_spaces(topsrcdir) + # normpath state_dir to normalize msys-style slashes. _activate_python_environment( topsrcdir, lambda: os.path.normpath(get_state_dir(True, topsrcdir=topsrcdir))