kubo / ruby-oci8

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

Refuses to build when `--with-instant-client-dir` is specified along with lib/include. #223

Closed dminuoso closed 3 years ago

dminuoso commented 4 years ago

The bug is triggered when --with-instant-client-dir is specified along with --with-instant-client-lib or --with-instant-client-include. Now arguably, that might be redundant, but it's a supported feature by extconf.

The error message you get is:

/home/dminuoso/wobcom/projects/apax-ng/ruby/2.6.0/bundler/gems/ruby-oci8-e94bd13faf53/ext/oci8/oraconf.rb:1034:in `initialize': Could not compile with Oracle
instant client. (RuntimeError)
'/nix/store/cyjjnng1ql1mqws3s1yv43x4vcq2msq7-oracle-instantclient-19.3.0.0.0-lib:/nix/store/cyjjnng1ql1mqws3s1yv43x4vcq2msq7-oracle-instantclient-19.3.0.0.0-lib:/nix/store/x9djqdr5gd3kxglc49s8vd1kdj72vh2h-oracle-instantclient-19.3.0.0.0/lib/libclntsh.so'
could not be found.
Did you install instantclient-basic?

The root cause is this: When --with-instant-client-dir is specified along side with any of the other two, then dir_config will construct a colon separated search path.

e.g. if you spceify:

--with-instant-client-dir=/dir --with-instant-client-lib=/lib

Then dir_config will produce something like ["/dir/include", "/dir/lib:/lib"]

That however means, one cannot just do

inc, lib = dir_config('instant-client")
... File.exist?("#{lib}/libclntsh.so")

Because that would test whether "/dir/lib:/lib/libclntsh.so" exists.

oraconf.rb has a couple of File.exists? calls in such a manner. A slightly better way would be to concoct some

def findLibrary(file, lib)
  p = lib.split(":").select do |b|
    File.exist?("#{b}/#{file}) }
  end

  if p
    "#{p}/#{file}"
  end
end

What do you think? (Maybe Im reinventing the wheel here, Im not deeply familiar with Rubys extconf).

kubo commented 3 years ago

Thanks for the report. I fixed it. It uses File::PATH_SEPARATOR instead of : for Windows.