Upgraded to macOS Mojave and now getting error in rails console

Viewed 2634

Upgraded to Mojave two days ago. Rails server is running but when I try to run activerecord stuff, I get error. When I try to run "Account.last" or "Account.new" or anything, it kicks me out and giving me following error

objc[38551]: +[__NSPlaceholderDictionary initialize] may have been in 
progress in another thread when fork() was called.
objc[38551]: +[__NSPlaceholderDictionary 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.

Ruby 2.3.4

Rails 5.1.6

Uninstalled few gems and tried but same error. It's killing me for last two days. And I am not only one facing this issue after upgrading.

3 Answers

put this export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES in your ~/.bash_profile

if you're using oh-my-zsh, edit ~/.zshrc and put this export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES at the beginning of file

and then reload your zsh config $ source ~/.zshrc

Are you using Postgres?

I started getting this error when running puma in cluster mode (specifying workers) after moving to a new computer (running macOS Catalina). The issue seemed to be a result of my psql version. OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES bundle exec rails s puma did work but I was not satisfied since everything was working without that env variable.

I moved my psql version from 12 to 9.5 and rebuilt the pg gem and it fixed the issue without the env variable:

brew uninstall postgres
brew install postgresql@9.5
brew link postgresql@9.5 --force
gem uninstall pg
bundle install

A coworker ran into the same issue today after upgrading to Mojave.

The problem got solved switching from unicorn-rails to puma server. So to get on on your daily work you can change the server in development/test to puma.

This is not a permanent solution but helps to locate where the issue is located and unblocks the developers workflow.

Related