Sergey Chechaev
Sergey Chechaev

Reputation: 570

how to install ruby-oci8 on centOS?

I am install Oracle Instant Client: Basic, SDK and SQL*Plus packages v 10.2.0.5.

mkdir /opt
mkdir /opt/oracle
cd /opt/oracle
unzip path/to/instantclient-basic-OS-VERSION.zip
unzip path/to/instantclient-sdk-OS-VERSION.zip
unzip path/to/instantclient-sqlplus-OS-VERSION.zip

after that i set vim ~/.oracle_client

    export ORACLE_HOME=/opt/oracle/
    export TNS_ADMIN=/admin/network/
    export LD_LIBRARY_PATH="/opt/oracle/instantclient_10_2/"

echo "source ~/.oracle_client" >> ~/.bash_profile source ~/.bash_profile

create tnsnames.ora and test connection sqlplus opsvod/agatb137@FESTEST

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Oct 31 14:55:17 2013

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

But whan i try to install gem install ruby-oci8 -v '2.1.5' i have error:

Building native extensions.  This could take a while...
ERROR:  Error installing ruby-oci8:
        ERROR: Failed to build gem native extension.

    /usr/local/bin/ruby extconf.rb
checking for load library path...
  LD_LIBRARY_PATH...
    checking /opt/oracle/instantclient_10_2/...   skip: /opt/oracle/instantclient_10_2/libclntsh.so.10.1 is for i386 cpu.
  checking ld.so.conf...   skip: /opt/oracle/instantclient_10_2/libclntsh.so.10.1 is for i386 cpu.
no
checking for cc... ok
checking for gcc... yes
checking for LP64... yes
checking for sys/types.h... yes
checking for ruby header... ok
Get the version of Oracle from SQL*Plus... *** 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=/usr/local/bin/ruby
        --with-instant-client
        --without-instant-client
/usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:760:in `get_version': RuntimeError (RuntimeError)
        from /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:709:in `initialize'
        from /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `new'
        from /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `get'
        from extconf.rb:18:in `<main>'
---------------------------------------------------
Error Message:
  cannot get Oracle version from sqlplus
Backtrace:
  /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:760:in `get_version'
  /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:709:in `initialize'
  /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `new'
  /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `get'
  extconf.rb:18:in `<main>'
---------------------------------------------------
See:
 * http://ruby-oci8.rubyforge.org/en/HowToInstall.html
 * http://ruby-oci8.rubyforge.org/en/ReportInstallProblem.html



Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/gem_make.out

How to resols this isue?

Upvotes: 1

Views: 2779

Answers (3)

quantum
quantum

Reputation: 3039

If you are by any chance trying to install this gem on Fedora 27 and are faced with a very similar error message, try to do:

dnf install rpm-build libnsl*

This fixed my errors (found it here).

EDIT: As of Fedora 28, libnsl* is no longer included as default dependency. This will make the ruby-oci8 gem fail for less than obvious reasons. The install directive above has been updated with this finding.

Upvotes: 0

Kubo Takehiro
Kubo Takehiro

Reputation: 424

skip: /opt/oracle/instantclient_10_2/libclntsh.so.10.1 is for i386 cpu.

The instant client is 32-bit.

checking for LP64... yes

The ruby is 64-bit.

The bitness of instant client must be same with that of ruby. You need 64-bit instant client to use with the 64-bit ruby.

Upvotes: 0

Pavling
Pavling

Reputation: 3963

We don't install the gem for our Oracle deployments, but build from source:

  1. Make sure that ORACLE_HOME is pointing to the oracle full client or oracle instaclient
  2. Make sure that inside the $ORACLE_HOME/lib libclntsh.so exists as a symbolic link to libclntsh.so.11.1
  3. Change into the ruby-oci8-2.1.x directory and run
    1. ruby setup.rb config
    2. ruby setup.rb setup
    3. ruby setup.rb install
  4. Install activerecord-oracle_enhanced-adapter ONLY WHEN the ruby-oci8 adapter is installed.

Upvotes: 1

Related Questions