Nonsense
Nonsense

Reputation: 290

Trouble installing ruby-oci8 gem

I'm trying to install a gem ruby-oci8 on the rails.

I get the following error,

$ gem install ruby-oci8

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

    current directory: /home/solovievga/.rvm/gems/ruby-2.4.2/gems/ruby-oci8-2.2.5.1/ext/oci8
/home/solovievga/.rvm/rubies/ruby-2.4.2/bin/ruby -r ./siteconf20180213-21757-1hli0rl.rb extconf.rb
checking for load library path...
  LD_LIBRARY_PATH is not set.
  checking ld.so.conf... no
checking for cc... ok
checking for gcc... yes
checking for LP64... yes
checking for sys/types.h... yes
checking for ruby header... ok
*** 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
        --without-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=/home/solovievga/.rvm/rubies/ruby-2.4.2/bin/$(RUBY_BASE_NAME)
        --with-instant-client
        --without-instant-client
/home/solovievga/.rvm/gems/ruby-2.4.2/gems/ruby-oci8-2.2.5.1/ext/oci8/oraconf.rb:909:in `get_home': RuntimeError (RuntimeError)
        from /home/solovievga/.rvm/gems/ruby-2.4.2/gems/ruby-oci8-2.2.5.1/ext/oci8/oraconf.rb:728:in `initialize'
        from /home/solovievga/.rvm/gems/ruby-2.4.2/gems/ruby-oci8-2.2.5.1/ext/oci8/oraconf.rb:269:in `new'
        from /home/solovievga/.rvm/gems/ruby-2.4.2/gems/ruby-oci8-2.2.5.1/ext/oci8/oraconf.rb:269:in `get'
        from extconf.rb:22:in `<main>'
---------------------------------------------------
Error Message:
  Set the environment variable ORACLE_HOME if Oracle Full Client.
  Append the path of Oracle client libraries to LD_LIBRARY_PATH if Oracle Instant Client.

Backtrace:
  /home/solovievga/.rvm/gems/ruby-2.4.2/gems/ruby-oci8-2.2.5.1/ext/oci8/oraconf.rb:909:in `get_home'
  /home/solovievga/.rvm/gems/ruby-2.4.2/gems/ruby-oci8-2.2.5.1/ext/oci8/oraconf.rb:728:in `initialize'
  /home/solovievga/.rvm/gems/ruby-2.4.2/gems/ruby-oci8-2.2.5.1/ext/oci8/oraconf.rb:269:in `new'
  /home/solovievga/.rvm/gems/ruby-2.4.2/gems/ruby-oci8-2.2.5.1/ext/oci8/oraconf.rb:269:in `get'
  extconf.rb:22:in `<main>'
---------------------------------------------------
See:
 * http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-full-client.md for Oracle full client
 * http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-instant-client.md for Oracle instant client
 * http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-on-osx.md for OS X
 * http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/report-installation-issue.md to report an issue.


To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/solovievga/.rvm/gems/ruby-2.4.2/extensions/x86_64-linux/2.4.0/ruby-oci8-2.2.5.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/solovievga/.rvm/gems/ruby-2.4.2/gems/ruby-oci8-2.2.5.1 for inspection.
Results logged to /home/solovievga/.rvm/gems/ruby-2.4.2/extensions/x86_64-linux/2.4.0/ruby-oci8-2.2.5.1/gem_make.out

I wonder how I can install the ruby-oci8 package?

Upvotes: 4

Views: 11722

Answers (4)

Junjie
Junjie

Reputation: 521

I have a similar problem installing the ruby-oci8 gem. In my case, there is already an app that uses it. When I deployed another app using the same gem, during bundle install, this error occurred. It asked for the LD_LIBRARY_PATH environment variable. Apparently, the installer of the old app did not set the variable to persist.

I thought that there should be an oracle library somewhere in the server so I searched for it. It was not in /opt but in /usr/lib. I set the variable to /usr/lib/oracle/11.1/client64/lib then the gem was installed smoothly.

Upvotes: 0

Aman Kumar
Aman Kumar

Reputation: 985

This solution worked for me

Before executing bundle install, Run below code on the console or add it to bash and source.

Export OCI_DIR=/opt/oracle/instantclient_12_2

Here /opt/oracle/instantclient_12_2 is path to instantclient on my mac machine.

You need to download instantclient from https://www.oracle.com/database/technologies/instant-client/downloads.html Unzip the download into /opt/oracle directory and export OCI_DIR environment variable.

Upvotes: 2

Anthony L
Anthony L

Reputation: 2169

These steps take you through the instant client installation process as well, just to provide some context. Download the instant and SDK zip files here:

http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

Unzip both files in the following directory as root.

/opt/oracle

Enter the instantclient_12_2 directory following the unzip and create a symlink for the libclntsh.so file:

ln -s libclntsh.so.12.1 libclntsh.so

Now, depending on your OS, you'll need to update your LD_LIBRARY_PATH location. In Ubuntu, do the following:

sudo nano /etc/ld.so.conf.d/moreLibs.conf

And enter the following in the file and save

/opt/oracle/instantclient_12_2

Now run the following command:

sudo ldconfig

And rerun your gem install

gem install ruby-oci8

Upvotes: 4

Ajay Barot
Ajay Barot

Reputation: 1680

You have to set LD_LIBRARY_PATH to install ruby-oci8 gem. Here I am assuming you are using linux os. Try this on your terminal.

$ LD_LIBRARY_PATH=$ORACLE_HOME/lib
$ export LD_LIBRARY_PATH
$ gem install ruby-oci8

Edit:

If you uses mswin32 ruby, use the following command instead.

gem install --platform x86-mingw32 ruby-oci8
  or
gem install --platform x64-mingw32 ruby-oci8

Let me know If you have any query or question.

Happy Coding

Upvotes: 4

Related Questions