kubo / ruby-oci8

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

`require': cannot load such file -- oci8lib_200 (LoadError) #214

Closed nabeelarshed closed 5 years ago

nabeelarshed commented 5 years ago

I have the following environment. Linux RH 7.3 ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux] oci8 version 2.6.2. irb result: [root@NYISYSRVA01 dev]# irb 2.6.2 :001 > 2.6.2 :002 > require 'oci8' Warning: NLS_LANG is not set. fallback to US7ASCII. => true BUT putting require 'oci8' in a file results in : /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- oci8lib_200 (LoadError) from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:inrequire' from /usr/local/rvm/gems/ruby-2.6.2/gems/ruby-oci8-2.2.7/lib/oci8.rb:107:in <top (required)>' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:135:inrequire' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:135:in rescue in require' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:144:inrequire' from ./test.rb:4:in `

'

The instant client directory looks like

[root@NYISYSRVA01 dev]# ls -l /opt/oracle/instantclient_12_2/ total 219848 -rwxrwxr-x. 1 root root 44220 Jan 26 2017 adrci -rw-rw-r--. 1 root root 363 Jan 26 2017 BASIC_README -rwxrwxr-x. 1 root root 57272 Jan 26 2017 genezi -r-xr-xr-x. 1 root root 342 Jan 26 2017 glogin.sql -rwxrwxr-x. 1 root root 8033199 Jan 26 2017 libclntshcore.so.12.1 lrwxrwxrwx. 1 root root 17 May 23 20:28 libclntsh.so -> libclntsh.so.12.1 -rwxrwxr-x. 1 root root 71638263 Jan 26 2017 libclntsh.so.12.1 -r-xr-xr-x. 1 root root 2981501 Jan 26 2017 libipc1.so -r-xr-xr-x. 1 root root 539065 Jan 26 2017 libmql1.so -r-xr-xr-x. 1 root root 6568149 Jan 26 2017 libnnz12.so -rwxrwxr-x. 1 root root 2218687 Jan 26 2017 libocci.so.12.1 -rwxrwxr-x. 1 root root 124771800 Jan 26 2017 libociei.so -r-xr-xr-x. 1 root root 158543 Jan 26 2017 libocijdbc12.so -r-xr-xr-x. 1 root root 380996 Jan 26 2017 libons.so -rwxrwxr-x. 1 root root 116563 Jan 26 2017 liboramysql12.so -r-xr-xr-x. 1 root root 1641005 Jan 26 2017 libsqlplusic.so -r-xr-xr-x. 1 root root 1559466 Jan 26 2017 libsqlplus.so -r--r--r--. 1 root root 4036257 Jan 26 2017 ojdbc8.jar drwxrwxr-x. 5 root root 97 Jan 26 2017 sdk -r-xr-xr-x. 1 root root 22751 Jan 26 2017 sqlplus -rw-rw-r--. 1 root root 367 Jan 26 2017 SQLPLUS_README -rwxrwxr-x. 1 root root 240476 Jan 26 2017 uidrvci -rw-rw-r--. 1 root root 74230 Jan 26 2017 xstreams.jar

STRACE

[root@NYISYSRVA01 lib]# strace -e trace=open -o strace.log ruby -roci8 -e "p OCI8" Warning: NLS_LANG is not set. fallback to US7ASCII. OCI8 [root@NYISYSRVA01 lib]# grep libruby.so strace.log open("/usr/local/rvm/rubies/ruby-2.6.2/lib/tls/x86_64/libruby.so.2.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/usr/local/rvm/rubies/ruby-2.6.2/lib/tls/libruby.so.2.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/usr/local/rvm/rubies/ruby-2.6.2/lib/x86_64/libruby.so.2.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/usr/local/rvm/rubies/ruby-2.6.2/lib/libruby.so.2.6", O_RDONLY|O_CLOEXEC) = 3

I will be grateful if you can help me in debugging this a bit more.

kubo commented 5 years ago

Could you put p RUBY_VERSION just before require 'oci8' in the test.rb script? I guess that the ruby used by test.rb was installed by rpm and the version is 2.0.x. You need to change the script to use ruby 2.6.2 installed by rvm.

nabeelarshed commented 5 years ago

Thank you so much, Kubo, for your prompt response. It is great to work with such code that is managed so professionally. The problem was indeed the environment being pulled by the script was different to the ruby installed by RVM.

Again thanks a lot.