kubo / ruby-oci8

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

Gem installing on cygwin but then not available #176

Closed bradoc closed 6 years ago

bradoc commented 6 years ago

Sorry, this is more of a support request, but maybe there is an issue.

I am trying to deploy a Rails 5 app on Cygwin on a Windows Server 2008 machine.

I have been able to install the latest ruby-oci8 gem (2.2.4.1) but when I run

ruby -e 'require "OCI8"'

I get the following output

/usr/share/ruby/2.3.0/fiddle.rb:47:in `initialize': No such file or directory (LoadError)
    from /usr/share/ruby/2.3.0/fiddle.rb:47:in `new'
    from /usr/share/ruby/2.3.0/fiddle.rb:47:in `dlopen'
    from /usr/share/ruby/2.3.0/Win32API.rb:15:in `initialize'
    from /home/pain-p/.gem/ruby/2.3.0/gems/ruby-oci8-2.2.4.1/lib/oci8/check_load_error.rb:11:in `new'
    from /home/pain-p/.gem/ruby/2.3.0/gems/ruby-oci8-2.2.4.1/lib/oci8/check_load_error.rb:11:in `<module:Util>'
    from /home/pain-p/.gem/ruby/2.3.0/gems/ruby-oci8-2.2.4.1/lib/oci8/check_load_error.rb:4:in `<class:OCI8>'
    from /home/pain-p/.gem/ruby/2.3.0/gems/ruby-oci8-2.2.4.1/lib/oci8/check_load_error.rb:3:in `<top (required)>'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/pain-p/.gem/ruby/2.3.0/gems/ruby-oci8-2.2.4.1/lib/oci8.rb:109:in `rescue in <top (required)>'
    from /home/pain-p/.gem/ruby/2.3.0/gems/ruby-oci8-2.2.4.1/lib/oci8.rb:114:in `<top (required)>'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:133:in `require'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:40:in `require'
    from -e:1:in `<main>'

Is this just a PATH issue? My current PATH is

/home/pain-p/perl5/bin:/usr/local/bin:/usr/bin:/bin:/cygdrive/c/Oracle/instantclient_12_2:/cygdrive/c/Program Files/FileMaker/FileMaker Server/Web Publishing/publishing-engine/php:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Program Files/Windows Imaging:/cygdrive/c/Ruby192/bin

kubo commented 6 years ago

Sorry, the real error message was hidden by the LoadError in check_load_error.rb.

First of all, could you run sqlplus? If you have not installed it, install it to c:\Oracle\instantclient_12_2 in advance. If sqlplus works, could you change /home/pain-p/.gem/ruby/2.3.0/gems/ruby-oci8-2.2.4.1/lib/oci8.rb as follows and try again to get the real error message?

begin
  require so_basename
rescue LoadError, OCIError
#  require 'oci8/check_load_error'    <- Comment this line
#  OCI8::Util::check_load_error($!)   <- Comment this line also
  raise
ensure
  dll_dir.remove if dll_dir
end
bradoc commented 6 years ago

Thankyou for the reply. I am only able to work on this on Monday and Friday. I will try this on Friday. I think I have installed sqlplus correctly so I will check that too.

On 16 October 2017 at 22:15, Kubo Takehiro notifications@github.com wrote:

Sorry, the real error message was hidden by the LoadError in check_load_error.rb.

First of all, could you run sqlplus? If you have not installed it, install it to c:\Oracle\instantclient_12_2 in advance. If sqlplus works, could you change /home/pain-p/.gem/ruby/2.3.0/ gems/ruby-oci8-2.2.4.1/lib/oci8.rb as follows and try again to get the real error message?

begin require so_basenamerescue LoadError, OCIError# require 'oci8/check_load_error' <- Comment this line# OCI8::Util::check_load_error($!) <- Comment this line also raiseensure dll_dir.remove if dll_dirend

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kubo/ruby-oci8/issues/176#issuecomment-336856256, or mute the thread https://github.com/notifications/unsubscribe-auth/AAdzoFX3wBvu9wsQ3Q-oNItCjiF26iNxks5sszrNgaJpZM4P6I3G .

kubo commented 6 years ago

OK.

Could you check whether "Microsoft Visual C++ 2013 Redistributable Package" is installed on your machine on Friday? Oracle client 12.2 depends on it. http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-instant-client.md#Windows

bradoc commented 6 years ago

Will do. I’m fairly sure it isn’t.

On Mon, 16 Oct 2017 at 10:23 pm, Kubo Takehiro notifications@github.com wrote:

OK.

Could you check whether "Microsoft Visual C++ 2013 Redistributable Package" is installed on your machine on Friday? Oracle client 12.2 depends on it.

http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-instant-client.md#Windows

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kubo/ruby-oci8/issues/176#issuecomment-336857998, or mute the thread https://github.com/notifications/unsubscribe-auth/AAdzoAfnsLIUJS2PYh7_b5szeOw8KxEUks5sszzOgaJpZM4P6I3G .

bradoc commented 6 years ago

Microsoft Visual C++ 2013 Redistributable Package was not installed so I have now done this.

I do not seem to be able to get sqlplus to run. When I run it from the command line I get

The procedure entry point K32GetModuleBaseNameA could not be located in the dynamic link library KERNEL32.DLL

If I make the changes to oci8.rb as requested then I get the following error message on calling ruby -e 'require "OCI8"'

/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': No such process - /home/pain-p/.gem/ruby/2.3.0/gems/ruby-oci8-2.2.4.1/ext/oci8/oci8lib_230.so (LoadError)
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/pain-p/.gem/ruby/2.3.0/gems/ruby-oci8-2.2.4.1/lib/OCI8.rb:107:in `<top (required)>'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:133:in `require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:40:in `require'
        from -e:1:in `<main>'

But I'm not sure this is helpful if sqlplus is not running.

If it is of any help, this machine has had a version of Oracle Instant Client (11.2) installed on it previously. Could this be causing conflicts?

kubo commented 6 years ago

Oracle instant client 12.2 doesn't work on Windows Server 2008. OCI.DLL calls GetModuleBaseName internally. When it is compiled without -DPSAPI_VERSION=1, it uses K32GetModuleBaseNameA in kernel32.dll. However the function is available since Windows Server 2008 R2. Oracle client 12.1 uses GetModuleBaseNameA in psapi.dll. The function is available since Windows 2000. So Oracle client 12.1 may be available on Windows Server 2008.

bradoc commented 6 years ago

Thankyou! I had actually realised that after thinking the error through while you were sending the message. I have tried installing the gem building against instant client 12.1 and both sqlplus and ruby-oci8 are now working fine! Thankyou for pointing me in the right direction.