diff --git a/build/mach_initialize.py b/build/mach_initialize.py index 8b6164ac63c2..84da39f6fb29 100644 --- a/build/mach_initialize.py +++ b/build/mach_initialize.py @@ -118,9 +118,11 @@ def _maybe_activate_mozillabuild_environment(): paths_to_add = [mozillabuild_msys_tools_path, mozillabuild / "bin"] existing_paths = [Path(p) for p in os.environ.get("PATH", "").split(os.pathsep)] + # It's important that we prepend to the path rather than append, + # in case mach is getting called from another msys2 environment. for new_path in paths_to_add: if new_path not in existing_paths: - os.environ["PATH"] += f"{os.pathsep}{new_path}" + os.environ["PATH"] = f"{new_path}{os.pathsep}" + os.environ["PATH"] def initialize(topsrcdir):