Featured image of post Fix macOS PHP NSCFConstantString Fork Error with One Env Var

Fix macOS PHP NSCFConstantString Fork Error with One Env Var

macOS artisan tinker throws an NSCFConstantString fork error when Guzzle is used. Set OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES in ~/.zshrc to fix it permanently.

When using Guzzle Client in artisan tinker, macOS throws objc[86150]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. This is caused by the Objective-C runtime’s safety check during fork.

Disable the Fork Safety Check

Set an environment variable to skip the check:

1
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

Add it to ~/.bashrc or ~/.zshrc so you don’t have to set it manually every time.