Rails:调用 fork() 时可能正在另一个线程中进行 [英] Rails: may have been in progress in another thread when fork() was called
问题描述
升级到 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
- 打开你的终端
- 通过键入 cd ~ 导航到您的主目录
- 在编辑器中打开 .bash_profile(VS Code 的代码,Atom 的 atom、vim、nano 等)纳米 .bash_profile
- 将 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屋!