Search code examples
ruby-on-railsrubyoraclemacos-mojaveoci8

Oracle instant client with gem ruby-oci8 not able to connect with DB in rails c


I am using Oracle instant client in my project and using ruby-oci8 gem. I am using Mac Mojave OS

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]

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.


Solution

  • 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