问题描述
我在我的项目中使用Oracle Instant Client,并使用ruby-oci8 gem.我正在使用Mac Mojave OS
I am using Oracle instant client in my project and using ruby-oci8 gem. I am using Mac Mojave OS
我能够运行rails server
并且服务器确实与数据库连接,但是当我运行rails c
并尝试与任何表连接时,它会引发以下错误.
I am able to run the rails server
and server does connect with database but when I run rails c
and try to connect with any table it throws following error.
Running via Spring preloader in process 95609
Loading development environment (Rails 5.1.1)
User.last
objc[96849]: +[__NSPlaceholderDictionary initialize] may have been in progress in another thread when fork() was called.
objc[96849]: +[__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.
/Users/arvindmehra/.rvm/gems/ruby-2.4.0/gems/ruby-oci8-2.2.5/lib/oci8/oci8.rb:142: [BUG] Illegal instruction at 0x007fff6efbf2e5
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin18]
我无法使用Rails控制台与DB连接,奇怪的是Rails服务器正在工作,并且Application能够与DB连接.
I am not able to connect with DB using rails console, strange thing is rails server is working and Application is able to connect with DB.
推荐答案
我终于能够通过将ruby版本升级到2.4.4
并添加export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
来解决它.我想问题在于OSX Mojave
和ruby-2.4.0
的组合,它实际上适用于OSX High Sierra
I was finally able to solve it by upgrading ruby version to 2.4.4
and adding export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
. I guess issue is with Combination of OSX Mojave
and ruby-2.4.0
and its actually working for OSX High Sierra
这篇关于具有gem ruby-oci8的Oracle Instant Client无法与Rails中的DB连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!