Skip to content

Commit

Permalink
Merge pull request #563 from rust-lang/fix-ansible-prevent-apply-scri…
Browse files Browse the repository at this point in the history
…pt-from-crashing-on-mac

fix(ansible): prevent apply script from crashing on mac
  • Loading branch information
marcoieni authored Sep 5, 2024
2 parents eafc8a6 + 5f8bc68 commit 11a726a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ansible/apply
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import shutil
import subprocess
import sys
import tempfile
import os
import platform

BASE_PATH = pathlib.Path(__file__).resolve().parent
VENV_PATH = BASE_PATH / ".venv"
Expand Down Expand Up @@ -74,7 +76,13 @@ def run_playbook(args):
ansible_args += ["-u", args.user]
if args.start_at_task is not None:
ansible_args += ["--start-at-task", args.start_at_task]
res = subprocess.run(ansible_args, cwd=str(tempdir))

env = os.environ.copy()
# Set environment variable if running on macOS to avoid python crash
if platform.system() == "Darwin":
env["OBJC_DISABLE_INITIALIZE_FORK_SAFETY"] = "true"

res = subprocess.run(ansible_args, cwd=str(tempdir), env=env)
if res.returncode != 0:
exit(1)
finally:
Expand Down

0 comments on commit 11a726a

Please sign in to comment.