Cannot install ruby-oci8 on Ubuntu 12.04LTS

Doing

$ bundle install 

For my rails application ... (3.2.8)

That's right when he gets to ruby-oci8 ...

  Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /home/ubuntu/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb checking for load library path... LD_LIBRARY_PATH... checking /usr/lib/oracle/12.1/client/... no checking ld.so.conf... no checking for cc... ok checking for gcc... yes checking for LP64... no 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 --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/ubuntu/.rvm/rubies/ruby-1.9.3-p448/bin/ruby --with-instant-client --without-instant-client /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:760:in `get_version': RuntimeError (RuntimeError) from /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:709:in `initialize' from /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `new' from /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/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: /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:760:in `get_version' /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:709:in `initialize' /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `new' /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/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 /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5 for inspection. Results logged to /home/ubuntu/.rvm/gems/ruby-1.9.3-p448/gems/ruby-oci8-2.1.5/ext/oci8/gem_make.out An error occurred while installing ruby-oci8 (2.1.5), and Bundler cannot continue. Make sure that `gem install ruby-oci8 -v '2.1.5'` succeeds before bundling. 

I did everything from every site and forum (especially from here). This one that I feel was the closest ... http://jigyasamakkar.com/ruby-oci8-with-rails-3-1-on-ubuntu/

What is the best way to solve this problem?

+7
ruby oracle ruby-on-rails ruby-on-rails-3
source share
2 answers

I recently had to install oracle + ruby ​​gem, here are the instructions for mac (but it will work just as well for ubuntu). Full instructions:

http://blog.codiez.co.za/2013/09/setup-oracle-instant-client-ruby-oci8-gem-mac/

The key is that in ruby-oci gem you need to know where the dynamic libraries are stored. For ubuntu you need to set: LD_LIBRARY_PATH

Take the following files:

  • instantclient-basic-linux.x64-11.2.0.3.0.zip
  • instantclient-sqlplus-linux.x64-11.2.0.3.0.zip
  • instantclient-sdk-linux.x64-11.2.0.3.0.zip

Extract them and place them somewhere, and then add the following environment variables. See the link for detailed instructions.

 export ORACLE_BASE=/usr/local/oracle export ORACLE_HOME=$ORACLE_BASE/product/instantclient_64/11.2.0.3.0 export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$DYLD_LIBRARY_PATH export TNS_ADMIN=$ORACLE_BASE/admin/network 

Explanation of environment variables:

ORACLE_BASE: Where all the files are stored ORACLE_HOME: Path to the actual client LD_LIBRARY_PATH: Must specify the lib directory, make sure you have a ZIP file SDK TNS_ADMIN: where you can find the TNS_ADMIN file (not necessary for ruby-oci gem)

+5
source share

For ruby-oci8 to work, it is important to install the instant client, the instant client SDK and the sqlplus instant client while we are on it. This is a good tool for :)

The best resource I could find on the Internet (works like a charm) is help.ubuntu.com, so a good reputable resource:

https://help.ubuntu.com/community/Oracle%20Instant%20Client

It uses rpms to install an instant client that can be executed through someone else's. In any case, all this is explained there.

To connect the OCI to your code, configure the TNS_ADMIN environment variable. I placed it in the same place as in the ubuntu community solution (in the same place where ORACLE_HOME is configured). I use the same folder standard as usual with oracle rdbms: network / admin.

For me it was: sudo vi / etc / profile.d / oracle.sh export ORACLE_HOME = / usr / lib / oracle / 11.1.0.1 / client export TNS_ADMIN = / usr / lib / oracle / network / admin

Then put your tnsnames.ora in the TNS_ADMIN folder.

Once this is done, just install the gem.

The Pearl WILL throw some errors / warnings, but they are not very important and still work. Reboot the session to get environment variables.

+2
source share

All Articles