kubo / ruby-oci8

Ruby-oci8 - Oracle interface for ruby
Other
169 stars 75 forks source link

GemRequireError with some Rake commands & oci8 #161

Closed antislice closed 3 years ago

antislice commented 7 years ago

I've had trouble with a couple rake commands when bundler is trying to load this gem. Installing the gem worked fine, and most actions I take are fine.

Issues with:

console log (they're similar for the different tasks):

%> rake spec
Warning: NLS_LANG is not set. fallback to US7ASCII.
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'ruby-oci8'. (Bundler::GemRequireError)
Gem Load Error is: OCI Library Initialization Error - /usr/local/opt/instantclient-basiclite/lib/libclntsh.dylib.12.1
Backtrace for gem load error is:
oci8lib.c:156:in oci8lib_230.bundle
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/ruby-oci8-2.2.3/lib/oci8.rb:72:in `<top (required)>'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/ruby-oci8-2.2.3/lib/ruby-oci8.rb:4:in `<top (required)>'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:91:in `require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:86:in `each'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:86:in `block in require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:75:in `each'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:75:in `require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler.rb:107:in `require'
/Users/homeslice/work/crisisresponse/config/application.rb:14:in `<top (required)>'
/Users/homeslice/work/crisisresponse/config/environment.rb:1:in `require'
/Users/homeslice/work/crisisresponse/config/environment.rb:1:in `<top (required)>'
/Users/homeslice/work/crisisresponse/spec/rails_helper.rb:3:in `require'
/Users/homeslice/work/crisisresponse/spec/rails_helper.rb:3:in `<top (required)>'
/Users/homeslice/work/crisisresponse/spec/controllers/authentications_controller_spec.rb:3:in `require'
/Users/homeslice/work/crisisresponse/spec/controllers/authentications_controller_spec.rb:3:in `<top (required)>'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1435:in `load'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1433:in `each'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:100:in `setup'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:86:in `run'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:71:in `run'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:45:in `invoke'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/exe/rspec:4:in `<main>'
Bundler Error Backtrace:
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:90:in `block (2 levels) in require'
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:86:in `each'
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:86:in `block in require'
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:75:in `each'
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:75:in `require'
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler.rb:107:in `require'
    from /Users/homeslice/work/crisisresponse/config/application.rb:14:in `<top (required)>'
    from /Users/homeslice/work/crisisresponse/config/environment.rb:1:in `require'
    from /Users/homeslice/work/crisisresponse/config/environment.rb:1:in `<top (required)>'
    from /Users/homeslice/work/crisisresponse/spec/rails_helper.rb:3:in `require'
    from /Users/homeslice/work/crisisresponse/spec/rails_helper.rb:3:in `<top (required)>'
    from /Users/homeslice/work/crisisresponse/spec/controllers/authentications_controller_spec.rb:3:in `require'
    from /Users/homeslice/work/crisisresponse/spec/controllers/authentications_controller_spec.rb:3:in `<top (required)>'
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1435:in `load'
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1433:in `each'
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:100:in `setup'
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:86:in `run'
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:71:in `run'
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:45:in `invoke'
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rspec-core-3.5.2/exe/rspec:4:in `<main>'

system info: macOS Sierra 10.12.3

file `which ruby` `: ~/.rvm/rubies/ruby-2.3.3/bin/ruby: Mach-O 64-bit executable x86_64
ruby --version: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
ruby -r rbconfig -e "p RbConfig::CONFIG['host']": x86_64-apple-darwin16.4.0
ruby -r rbconfig -e "p RbConfig::CONFIG['CC']": gcc
ruby -r rbconfig -e "p RbConfig::CONFIG['CFLAGS']": -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe

ruby -r rbconfig -e "p RbConfig::CONFIG['LDSHARED']": gcc -dynamic -bundle
ruby -r rbconfig -e "p RbConfig::CONFIG['LDFLAGS']": -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib

ruby -r rbconfig -e "p RbConfig::CONFIG['DLDLAGS']": -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib

ruby -r rbconfig -e "p RbConfig::CONFIG['LIBS']": -lpthread -ldl -lobjc
ruby -r rbconfig -e "p RbConfig::CONFIG['GNU_LD']": no

gcc

gcc --print-prog-name=ld: /Library/Developer/CommandLineTools/usr/bin/ld gcc --print-prog-name=as: /Library/Developer/CommandLineTools/usr/bin/as

Oracle

Don't have Oracle full client

Oracle instant client:

%> file $OCI_DIR/libclntsh.*
/usr/local/lib/libclntsh.dylib:      Mach-O 64-bit dynamically linked shared library x86_64
/usr/local/lib/libclntsh.dylib.12.1: Mach-O 64-bit dynamically linked shared library x86_64

echo $LD_LIBRARY_PATH
(nothing)

echo $DYLD_LIBRARY_PATH    # Mac OS X
(nothing)

I was under the impression that El Capitan and later wouldn't have $DYLD_LIBRARY_PATH set however.

kubo commented 7 years ago

The easiest may be (1) installing instantclient from brew and (2) installing instantclient to $HOME/lib.

$ brew uninstall instantclient-basiclite
$ brew uninstall instantclient-sdk
$ mkdir $HOME/lib
$ unzip instantclient-basiclite-macos.x64-12.1.0.2.0.zip
$ cp instantclient_12_1/* $HOME/lib

IMO, you have no need to recompile ruby-oci8.

I have not upgrade my macbookair to macOS Sierra yet. There may be Sierra-specific issue or brew may fix install names and rpaths in the Oracle client libraries but the fix may cause bad effect.

antislice commented 7 years ago

Ok, I tried that and also a few other things.

The initial set of instructions led to this:

%> bundle exec rake spec
rake aborted!
LoadError: dlopen(/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/ruby-oci8-2.2.3/lib/oci8lib_230.bundle, 9): Library not loaded: /usr/local/opt/instantclient-basiclite/lib/libclntsh.dylib.12.1
  Referenced from: /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/ruby-oci8-2.2.3/lib/oci8lib_230.bundle
  Reason: image not found - /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/ruby-oci8-2.2.3/lib/oci8lib_230.bundle
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/ruby-oci8-2.2.3/lib/oci8.rb:72:in `<top (required)>'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/ruby-oci8-2.2.3/lib/ruby-oci8.rb:4:in `<top (required)>'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:91:in `require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:86:in `each'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:86:in `block in require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:75:in `each'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler/runtime.rb:75:in `require'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.3/lib/bundler.rb:107:in `require'
/Users/homeslice/work/crisisresponse/config/application.rb:14:in `<top (required)>'
/Users/homeslice/work/crisisresponse/Rakefile:4:in `require'
/Users/homeslice/work/crisisresponse/Rakefile:4:in `<top (required)>'
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
/Users/homeslice/.rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:in `eval'
/Users/homeslice/.rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)

I followed that with changing my OCI_DIR and the full instructions on installing without homebrew, which led to the same stack trace as above. Also tried linking the directory of the library it can't seem to find (ln -s ~/lib/instantclient_12_1 /usr/local/opt/instantclient-basiclite), didn't make a difference.

At that point I tried reinstalling the gem, bundle exec gem pristine ruby-oci8, which failed because it couldn't find ruby-oci8-2.2.3 with a GemNotFound error. The next step was bundle install, which also failed and the log/gem_make.out is below:

%> cat /Users/homeslice/.rvm/gems/ruby-2.3.3/extensions/x86_64-darwin-16/2.3.0/ruby-oci8-2.2.3/gem_make.out
current directory: /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/ruby-oci8-2.2.3/ext/oci8
/Users/homeslice/.rvm/rubies/ruby-2.3.3/bin/ruby -r ./siteconf20170209-44368-1abw1a9.rb extconf.rb 
checking for load library path... 
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/homeslice/.rvm/rubies/ruby-2.3.3/bin/$(RUBY_BASE_NAME)
    --with-instant-client
    --without-instant-client
/Users/homeslice/.rvm/gems/ruby-2.3.3/gems/ruby-oci8-2.2.3/ext/oci8/oraconf.rb:575:in `check_ic_dir': RuntimeError (RuntimeError)
    from /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/ruby-oci8-2.2.3/ext/oci8/oraconf.rb:316:in `get'
    from extconf.rb:22:in `<main>'
  DYLD_LIBRARY_PATH is not set.
  DYLD_FALLBACK_LIBRARY_PATH is not set.
  checking OCI_DIR...
    checking /Users/homeslice/lib... no
  checking the default value of DYLD_FALLBACK_LIBRARY_PATH...
    checking /Users/homeslice/lib... no
    checking /usr/local/lib... no
    checking /lib... no
    checking /usr/lib... no
---------------------------------------------------
Error Message:
  Set the environment variable DYLD_LIBRARY_PATH, DYLD_FALLBACK_LIBRARY_PATH or
  OCI_DIR to point to the Instant client directory.

  If DYLD_LIBRARY_PATH or DYLD_FALLBACK_LIBRARY_PATH is set, the environment
  variable must be set at runtime also.

  If OCI_DIR is set, dependent shared library paths are checked. If the checking
  is passed, ruby-oci8 works without DYLD_LIBRARY_PATH or DYLD_FALLBACK_LIBRARY_PATH.

  Note: OCI_DIR should be absolute path.
  Note: DYLD_* environment variables are unavailable for security reasons on OS X 10.11 El Capitan.

Backtrace:
  /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/ruby-oci8-2.2.3/ext/oci8/oraconf.rb:575:in `check_ic_dir'
  /Users/homeslice/.rvm/gems/ruby-2.3.3/gems/ruby-oci8-2.2.3/ext/oci8/oraconf.rb:316:in `get'
  extconf.rb:22:in `<main>'
---------------------------------------------------
See:
 * http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-full-client.md for Oracle full client
 * http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-instant-client.md for Oracle instant client
 * http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-on-osx.md for OS X
 * http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/report-installation-issue.md to report an issue.

extconf failed, exit code 1

My original issue is not particularly urgent at the moment, since those rake tasks aren't mission critical at this time. The install with Homebrew worked for me otherwise, so I'll be going back to that for the time being. Thanks!

deepj commented 7 years ago

I have the similar issue. What's a strange on this thing it has started today. I'm not sure what changes I made before.

After invoking rails s I'm getting this issue

$ rails s
~/.gem/ruby/2.3.1/gems/bundler-1.14.5/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'ruby-oci8'. (Bundler::GemRequireError)
Gem Load Error is: OCI Library Initialization Error - /usr/local/opt/instantclient-basiclite/lib/libclntsh.dylib.12.1
Backtrace for gem load error is:
oci8lib.c:156:in oci8lib_230.bundle
~/.gem/ruby/2.3.1/gems/ruby-oci8-2.2.3/lib/oci8.rb:72:in `<top (required)>'
~/.gem/ruby/2.3.1/gems/ruby-oci8-2.2.3/lib/ruby-oci8.rb:4:in `require'
kubo commented 3 years ago

Closed due to inactivity, feel free to open another ticket if the problem persists.