Rails:调用 fork() 时可能正在另一个线程中进行 [英] Rails: may have been in progress in another thread when fork() was called

查看:42
本文介绍了Rails:调用 fork() 时可能正在另一个线程中进行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级到 OS10.14 后,当我调用 Httparty

After I upgrade to OS10.14, I got this error when I called Httparty

    response = HTTParty.get('http://api.stackexchange.com/2.2/questions?site=stackoverflow')
objc[4182]: +[__NSPlaceholderDictionary initialize] may have been in progress in another thread when fork() was called.
objc[4182]: +[__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.

我已经试过了在我启动 rails 控制台之前导出 OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES.

但是没有用.

推荐答案

在 rails 控制台之前运行 workaround 命令是不够的.

It is not enough running the workaround command before rails console.

以下解决方案对我有用(按照此说明进行操作):

The following solution worked for me (follow this instructions):

如果您遇到此错误,您可以将以下代码添加到位于您的主目录中的 .bash_profile 以解决该问题.

If you encounter this error, you can add the code below to your .bash_profile located in your home directory to fix the issue.

export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

  1. 打开你的终端
  2. 通过键入 cd ~ 导航到您的主目录
  3. 在编辑器中打开 .bash_profile(VS Code 的代码,Atom 的 atom、vim、nano 等)纳米 .bash_profile
  4. 将 export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES 复制并粘贴到您的文件中(确保它位于文件底部的 RVM 部分上方!)

* 这很重要 *在我的 .bash_profile 中,它是这样的:

* THIS IS IMPORTANT * In my case into .bash_profile it is something like this:

export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM$

保存文件并退出所有编辑器和终端会话.重新打开您的编辑器,现在一切正常.

Save the file and quit all editor and terminal sessions. Reopen your editor and everything should now work normally.

我在这个链接上找到了这个解决方案 科迪克莱门斯个人​​博客

I found this solution at this link Kody Clemens Personal Blog

这篇关于Rails:调用 fork() 时可能正在另一个线程中进行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆