Bug 1801826 - Prepend rather than append mozillabuild path. r=ahochheiden

This makes sure that we find the right tools in the right msys2
environment in case we get called from another msys2 env.

Differential Revision: https://phabricator.services.mozilla.com/D162753
This commit is contained in:
Emilio Cobos Álvarez 2022-11-23 18:17:28 +00:00
parent b40bfc63bc
commit 26d1a61070

View file

@ -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):