Skip to main content
🎤 Speaking at Red Hat Summit 2026 GPUs take flight: Safety-first multi-tenant Platform Engineering with NVIDIA and OpenShift AI Learn More
Cover for Why Ansible and Python fork break on macOS High Sierra+ and how to solve
kcs

Fix Ansible and Python fork on macOS High Sierra+

Running into Python or Ansible crashes on macOS High Sierra+? This guide explains why fork-related errors happen—and how to fix them for good with a.

LB
Luca Berton
· 1 min read

Environment

macOS High Sierra+

Issue

objc[22868]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[22868]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

Resolution

  • current session only
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
  • for all future sessions
$ echo "OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES" >> .bash_profile

Save, exit, close terminal and re-open the terminal. Verify with:

$ env
[...]
OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

Root Cause

This error is caused by an added security to restrict multithreading in macOS High Sierra and later versions.

Apple has defined some rules on what is allowed and not allowed after forking and they have also added async-signal-safety to a limited number of APIs.

#macOS #howto
Share:

📬 Don't miss the next one

Get AI & Cloud insights delivered weekly

Join engineers getting practical tips on AI, Kubernetes, Ansible, and Platform Engineering.

Subscribe Free →
Luca Berton — AI & Cloud Advisor, Docker Captain

Luca Berton

AI & Cloud Advisor · Docker Captain · KubeCon Speaker

18+ years in enterprise infrastructure. Author of 8 technical books, creator of Ansible Pilot (1M+ YouTube views, 648K site users). Former Red Hat engineer. Speaker at KubeCon EU 2026 and Red Hat Summit 2026.

Luca Berton Ansible Pilot Ansible by Example Open Empower K8s Recipes Terraform Pilot CopyPasteLearn ProteinLens Heaven Art Shop TechMeOut

Free 30-min AI & Cloud consultation

Book Now