3

I am running under macOS Catalina version 10.15.1 When I run my rails console on my project and try to perform a query like User.first I get :

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

I followed this answer and added OBJC_DISABLE_INITIALIZE_FORK_SAFETY to my .zshrcfile which looks like that :

ZSH=$HOME/.oh-my-zsh

# You can change the theme with another one:
#   https://github.com/robbyrussell/oh-my-zsh/wiki/themes
ZSH_THEME="robbyrussell"

# Useful oh-my-zsh plugins for Le Wagon bootcamps
plugins=(git gitfast zsh-autosuggestions last-working-dir zsh-syntax-highlighting common-aliases history-substring-search)

# Prevent Homebrew from reporting - https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Analytics.md
export HOMEBREW_NO_ANALYTICS=1

# Actually load Oh-My-Zsh
source "${ZSH}/oh-my-zsh.sh"
unalias rm # No interactive rm by default (brought by plugins/common-aliases)


export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

# Load rbenv if installed (To manage your Ruby versions)
export PATH="${HOME}/.rbenv/bin:${PATH}"
type -a rbenv > /dev/null && eval "$(rbenv init -)"

# Load nvm if installed (To manage your Node versions)
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"

# Anaconda binaries (python, pip, conda, jupyter, pytest, pylint etc.)
export PATH="/anaconda3/bin:${HOME}/anaconda3/bin:${PATH}"



# Rails and Ruby uses the local `bin` folder to store binstubs.
# So instead of running `bin/rails` like the doc says, just run `rails`
# Same for `./node_modules/.bin` and nodejs
export PATH="./bin:./node_modules/.bin:${PATH}:/usr/local/sbin"

# Store your own aliases in the ~/.aliases file and load the here.
[[ -f "$HOME/.aliases" ]] && source "$HOME/.aliases"

# Encoding stuff for the terminal
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export EDITOR=atom

When I run in my terminal echo $OBJC_DISABLE_INITIALIZE_FORK_SAFETY I get YES, so I think the environment variable is correcly set... but that doesnt fix the issue.

How can I fix this problem ?

Community
  • 1
  • 1
David Geismar
  • 3,152
  • 6
  • 41
  • 80

2 Answers2

3

What worked for me, was disbaling Spring: export DISABLE_SPRING=true before starting your Rails console or server

Jan
  • 12,992
  • 9
  • 53
  • 89
1

I ran into this problem after I updated my Postgres database. I ended up updating to the latest ruby version and reinstalling all gems. After that everything worked again.

I tried the OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES suggestion as well, to no avail.

eikes
  • 4,811
  • 2
  • 31
  • 31