Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #1027 (closed defect: invalid)

Opened 4 years ago

Last modified 2 years ago

OCI8 APACHE define_a_column

Reported by: john.elrick@gmail.com Assigned to: David
Priority: high Milestone: 1.0
Component: ActiveRecord Version: 0.11.0
Severity: normal Keywords:
Cc:

Description

<pre> Attempting remote installation of 'rails' ERROR: While executing gem ... (NameError)

undefined method define_a_column' for class OCI8::Cursor'

</pre>

This actually throws a neat little exception box complaining that the OCI dll was not found.

I believe that the culprit might be in oci_adapter.rb


require 'active_record/connection_adapters/abstract_adapter'

begin

require_library_or_gem 'oci8' unless self.class.const_defined? :OCI8

module ActiveRecord

---

The require should be conditional. Stops my installation cold.

Change History

04/09/05 15:10:59 changed by nzkoz

  • milestone set to 1.0.

04/19/05 06:27:55 changed by anonymous

I got the same error when attempting to do anything at all after installing the OCI8 driver.

I am new to Ruby. FWIW, I think the issue is the alias of the method before its use. Moving the alias after the def define_a_column seems to solve the problem.

04/19/05 09:51:51 changed by anonymous

This is happening to me on Mac OS X (10.3.9) as well.

04/20/05 13:31:30 changed by mparrish@pearware.org

I'm also seeing this error message on Linux. I tried moving the alias after the method definition, and I got further, but I'm still unable to query the database. I'm not sure if that problem is related or not, but things were working properly before.

04/29/05 10:40:27 changed by anonymous

When oci8.rb is installed but the environment variables which are necessary to find OCI.dll(Windows) or libclntsh.so(UNIX) by oci8lib.so aren't set, it causes the error.

scenario: * require_library_or_gem 'oci8' in oci_adapter.rb:22. * require 'oci8' in abstract_adapter.rb:10. * find oci8.rb in $LOAD_PATH in eval.c. * register 'oci8.rb' to $LOADED_FEATURES in eval.c. * load 'oci8.rb' in eval.c. * require 'oci8lib' in oci8.rb:7. * find oci8lib.so in $LOAD_PATH in eval.c. * register 'oci8lib.so' to $LOADED_FEATURES in eval.c. * raise a LoadError when OCI.DLL(Windows) or libclntsh.so(Linux) isn't found. * rescue the LoadError in abstract_adapter.rb:11. * require 'oci8' again in abstract_adapter.rb:20. * no error because 'oci8.rb' has been already included by $LOADED_FEATURES. * require_library_or_gem causes no error even though oci8 isn't loaded properly.

05/02/05 14:06:18 changed by mparrish@pearware.org

I'm getting this error on linux when I run in irb

irb(main):001:0> require 'rubygems' => true irb(main):002:0> require 'active_record' NameError: undefined method define_a_column' for class OCI8::Cursor'

from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/connection_adapters/oci_adapter.rb:252 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.0.4/lib/active_support/dependencies.rb:197:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record.rb:69 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:175:in `activate' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:23:in `require' from (irb):2

05/02/05 14:07:19 changed by mparrish@pearware.org

Sorry, bad formatting...

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'active_record'
NameError: undefined method `define_a_column' for class `OCI8::Cursor'
        from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/connection_adapters/oci_adapter.rb:252
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require'
        from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.0.4/lib/active_support/dependencies.rb:197:in `require'
        from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record.rb:69
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:175:in `activate'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:23:in `require'
        from (irb):2

05/03/05 17:01:21 changed by mparrish@pearware.org

I am no longer having this issue. It turns out that the oracle instantclient library was not on the library path, so it wasn't being found. Once I solved that, rails started working normally.

06/10/05 12:33:31 changed by minam

  • status changed from new to closed.
  • resolution set to invalid.

This error will only happen when you have OCI8 installed, but don't have your library path set up correctly for OCI8 to locate the Oracle libraries. (If anyone is having this problem under other circumstances, please holler.)

Thus, it is not a Rails issue, but rather an issue with your setup of the OCI8 library and/or Oracle. I'm marking this ticket invalid.

07/01/05 18:47:49 changed by hank

Make sure if in Linux that you have permissions to access oracle home. I wasn't running as my oracle user, and the user I was running as didn't have perms to access oracle's files - pretty much because I only installed OCI for testing. Just watch out for that one.

08/16/05 08:37:37 changed by Diego

sorry, Newbie question. how do I set up my library path correctly? is this like an env variable? vim etc/profile? Or is it in the config area of my app?

08/18/05 08:48:14 changed by tai

Diego: I just reinstalled oci8 (it took about 30 seconds to download and install), and the problem went away. Give it a try!

08/18/05 08:51:14 changed by tai

Diego: I just reinstalled oci8 (it took about 30 seconds to download and install), and the problem went away. Give it a try!

02/17/06 12:28:38 changed by Wagner

These steps worked for me under windows xp:

1- Download oracle instant client from oracle website;

2- Unzip it;

3- At "envoirments variables", add the dir you just unzipped to PATH;

4- Run irb, try:

require 'oci8'

5- If you got an error, search for all files called oci.dll on your system, make sure there are only one (the one that is under your "instant client" dir). Rename the olders files to something like oci.dll_ an try irb again.

05/11/06 05:25:25 changed by kevin@zoove.com

  • severity changed from blocker to normal.
  • summary changed from OCI.dll error during Gem Install On Windows to OCI8 APACHE define_a_column.

I think that most people have problems with this when setting up on APACHE. I just figured out how this works and I am going to do a complete walk through in the next few days on how to set up RubyOnRails with Apache and OCI8. But the short of the matter is that you have to add ..... SetEnv LD_LIBRARY_PATH /<dir>/instantclient_10_2 ... to your httpd.conf file.

I hope this helps