kubo / ruby-oci8

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

Another Error with: 'require': OCI.dll: 126 (The Specifiede module could note be...) #208

Closed yurifarod closed 3 years ago

yurifarod commented 5 years ago

Hello fellows, I have seens another Erros simillars to mine, but the solution proposals for the other cases don't work to me. I install the gems "dbi" and "ruby-oci8" with success. When i call the gems in the "irb" i have the answer TRUE to the command require 'dbi'. But when i command "require 'ruby-oci8'" or "require 'oci8'" the "irb" returns me this error: LoadError OCI.dll: 126 (The Specifiede module could note be...) I'm using a Windows 10 OS, i have the OCI.dll directory on the Path and a ORACLE_HOME in the environment variables. I daily use de instantclient in my work. All the other gems are working perfectly here. Anybody can help me?

kubo commented 5 years ago

Could you check whether required MSVC redistributeable package is installed? See: https://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-instant-client.md#Windows

yurifarod commented 5 years ago

Yes, inside my instant client directory have a "MSVCR71.DLL"

kubo commented 5 years ago

Could you post the following information?

ruby --version
cd \path-to-oracle-instant-client  # Change this line
dir
yurifarod commented 5 years ago

return for "ruby --version"

ruby_ 2.4.4p296 (2018-03-28 revision 63013) [x64-mingw32]

Now i use

cd %ORACLE_HOME% dir

and this return...

11/10/2018 08:16

. 11/10/2018 08:16 .. 15/09/2014 22:08 20.480 adrci.exe 11/10/2018 08:15 ASP.NET 11/10/2018 08:16 bin 11/10/2018 08:17 cfgtoollogs 27/08/2008 13:03 1.594.191 classes12.jar 11/10/2018 08:14 diagnostics 27/08/2008 13:03 766 dos.ico 27/08/2008 13:03 766 editar.ico 15/09/2014 21:36 66.560 genezi.exe 15/09/2014 21:36 28.163 genezi.sym 13/09/2014 12:44 10.240 heteroxa12.dll 13/09/2014 12:44 4.457 heteroxa12.sym 11/10/2018 08:16 install 11/10/2018 08:16 inventory 11/10/2018 08:14 jdbc 11/10/2018 08:14 jdk 02/09/2008 08:10 2.273 LEIA-ME.txt 27/08/2008 13:03 1.078 leiame.ico 11/10/2018 08:15 lib 11/10/2018 08:15 light 11/10/2018 08:16 log 11/10/2018 08:14 META-INF 27/08/2008 13:03 348.160 msvcr71.dll 11/10/2018 08:15 Network 11/10/2018 08:14 nls 15/09/2014 21:28 1.015.808 oci.dll 27/08/2008 13:03 344.064 oci.dll.o.10-11-2018_08-14-58 15/09/2014 21:28 275.394 oci.sym 27/08/2008 13:03 82.192 ocijdbc10.dll 13/09/2014 12:46 101.376 ocijdbc12.dll 13/09/2014 12:46 16.955 ocijdbc12.sym 15/09/2014 21:11 345.088 ociw32.dll 15/09/2014 21:11 34.127 ociw32.sym 11/10/2018 08:15 ODACDoc 11/10/2018 08:14 odbc 11/10/2018 08:16 odp.net 11/10/2018 08:16 odt 27/08/2008 13:03 1.540.457 ojdbc14.jar 29/08/2014 05:14 3.692.104 ojdbc6.jar 11/10/2018 08:15 oledb 11/10/2018 08:14 OPatch 11/10/2018 08:15 44 Oracle.Key 04/08/2014 09:24 87.337 orai18n-mapping.jar 04/08/2014 09:24 1.659.626 orai18n.jar 11/10/2018 08:15 oramts 11/08/2014 03:24 22.528 orannzmcs12.dll 27/08/2008 13:03 1.093.632 orannzsbb10.dll 11/08/2014 03:24 4.269.056 orannzsbb12.dll 27/08/2008 13:03 778.240 oraocci10.dll 15/09/2014 20:28 645.632 oraocci12.dll 15/09/2014 21:36 516.993 oraocci12.sym 27/08/2008 13:03 91.119.616 oraociei10.dll 15/09/2014 21:34 161.739.776 oraociei12.dll 15/09/2014 21:34 5.564.631 oraociei12.sym 12/08/2014 17:08 178.688 oraons.dll 15/09/2014 21:26 728.576 orasql12.dll 15/09/2014 21:26 30.000 orasql12.sym 27/08/2008 13:03 1.650.688 orasqlplusic10.dll 12/08/2014 13:20 1.563.136 orasqlplusic12.dll 15/09/2014 21:11 46.080 oravssmsg.dll 15/09/2014 21:11 46.080 oravssmsgUS.dll 15/09/2014 21:12 168.448 oravssw.exe 15/09/2014 21:15 208.896 orawsec12.dll 15/09/2014 15:16 5.120 orawsecmsgus.dll 11/10/2018 08:15 oui 11/10/2018 08:15 rdbms 11/10/2018 08:15 relnotes 19/09/2018 12:11 sqlplus 12/08/2014 13:19 679.424 sqlplus.exe 12/08/2014 13:20 86.688 sqlplus.sym 15/09/2014 21:16 568.832 sqora32.dll 15/09/2014 21:16 126.464 sqoras32.dll 15/09/2014 21:16 17.408 sqresja.dll 15/09/2014 21:16 18.944 sqresus.dll 14/03/2018 07:52 1.237 TNSNAMES.ORA 15/09/2014 22:08 20.480 uidrvci.exe 12/09/2018 10:32 7.477 unins000.dat 12/09/2018 10:31 697.376 unins000.exe 12/09/2018 10:32 10 uninsTasks.txt 15/09/2014 22:08 362.496 wrc.exe 07/07/2014 04:10 71.202 xstreams.jar

Thank u again for the help

kubo commented 5 years ago

ruby_ 2.4.4p296 (2018-03-28 revision 63013) [x64-mingw32]

The ruby is for Windows x64. You need to use Oracle instant client for Windows x64.

15/09/2014 21:28 1.015.808 oci.dll

However this seems Oracle instant client 12.1.0.2.0 for Windows 32-bit according to the timestamp and the file size.

$ unzip -l instantclient-basic-nt-12.1.0.2.0.zip | grep oci.dll # on linux
  1015808  2014-09-16 11:28   instantclient_12_1/oci.dll

2014-09-16 11:28 +09:00 => 2019-06-15 21:28 -05:00

yurifarod commented 5 years ago

I see that, in my environment i can't change my intant client, but in my python scripts i have a resource to use other version of instant client with this code: os.chdir("C:\\app\\client\\12.1.0\\client_1")

have a similar code in ruby?

kubo commented 5 years ago

How about ENV['PATH'] = "C:\\app\\client\\12.1.0\\client_1;" + ENV['PATH'] before require 'oci8'.

yurifarod commented 5 years ago

Just like this?

require "dbi" ENV['PATH'] = "C:\app\client\12.1.0\client_1;" + ENV['PATH'] require "oci8"

dbh = DBI.connect('DBI:OCI8:DBASE', 'user', 'password') dbh.disconnect

Did not work.

kubo commented 5 years ago

When you use double quotes, backslashes must be escaped as "C:\\app\\client\\12.1.0\\client_1;". When you don't want to escape backslashes, you need to use single quotes as 'C:\app\client\12.1.0\client_1;'.

yurifarod commented 5 years ago

I tried the both strings, none works.

kubo commented 5 years ago

I tried the both strings, none works.

I would like to confirm just in case. Did you get same errors; OCI.DLL: 126(The specified module could not be found. )? Is the OCI.DLL in C:\app\client\12.1.0\client_1 for Windows x64, not for Windows 32-bit? Did you install Microsoft Visual C++ 2013 Redistributable Package to use Oracle instant client 12.1?

yurifarod commented 5 years ago

Yes, i use this client 12.1 in other project with Python. The oci.dll is x64

kubo commented 5 years ago

Do you use ruby distributed by rubyinstaller.org?

Could you change these lines as follows and post the output?

    filename = File.join(path, 'OCI.DLL')
    arch = dll_arch.call(filename)
    puts("#{filename}: #{arch}")  # I want to know this output.
    if arch == ruby_arch
      dll_dir = RubyInstaller::Runtime.add_dll_directory(path)
      break
    end
yurifarod commented 5 years ago

The return is: undefined local variable or methodpath' for main"` But the my oci.dll is in my path (on the environment variables), it's necessary to my DB architecture.

kubo commented 5 years ago

@yurifarod You misunderstood what I wrote here. Could you replace these lines in oci8.rb installed on your machine and post its output?

What ruby do you use? Is it the ruby distributed by rubyinstaller.org?

kubo commented 5 years ago

If you use ruby-oci8 2.2.3 or earlier with ruby 2.4.4 distributed by rubyinstaller.org, it doesn't work. That's because rubyinstaller.org distributes customized rubies which restrict DLL search path. If you need to use old ruby-oci8, set RUBY_DLL_PATH.

yurifarod commented 5 years ago

I use ruby-oci8-2.2.6.1-x64-mingw32 with the ruby 2.4.4 distributed by rubyinstaller.org. It work? I understand the changes in the oci8 now, i'll do this and return the result.

kubo commented 3 years ago

Sorry for no reply. I closed this due to inactivity, feel free to open another ticket if the problem persists.