rails 2.2.0 - config.gem "activerecord-oracle_enhanced-adapter" -- no such file to load

998 views
Skip to first unread message

Mattia

unread,
Dec 14, 2008, 10:03:19 PM12/14/08
to Oracle enhanced adapter for ActiveRecord
Hello again,

a smaller issue when I set the activerecord-oracle_enhanced-adapter
gem dependency in my config/environment.rb:

no such file to load -- activerecord/oracle_enhanced/adapter
/opt/ruby-enterprise-1.8.6-20080810/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in `gem_original_require'
/opt/ruby-enterprise-1.8.6-20080810/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in `require'
.../vendor/rails/activesupport/lib/active_support/dependencies.rb:
148:in `require'
.../vendor/rails/activesupport/lib/active_support/dependencies.rb:
507:in `new_constants_in'
.../vendor/rails/activesupport/lib/active_support/dependencies.rb:
148:in `require'
.../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:91:in
`load'
.../config/../vendor/rails/railties/lib/initializer.rb:277:in
`load_gems'
.../config/../vendor/rails/railties/lib/initializer.rb:277:in `each'
.../config/../vendor/rails/railties/lib/initializer.rb:277:in
`load_gems'
.../config/../vendor/rails/railties/lib/initializer.rb:161:in
`process'
.../config/../vendor/rails/railties/lib/initializer.rb:112:in `send'
.../config/../vendor/rails/railties/lib/initializer.rb:112:in `run'
.../config/environment.rb:15

Now, what is really odd is that apache" + mod_rails are working fine,
with or without that config.gem. Speaking of oddities (which might be
unrelated):

$ ruby -r oci8 -e "OCI8.new('c', 'b','c').exec('select * from dual')
do |r| puts r.join(','); end"
ruby: no such file to load -- oci8 (LoadError)

$ irb
>> require 'oci8'
=> true
>> OCI8.new('c', 'b','c').exec('select * from dual') do |r| puts r.join(','); end
=> 1

The activerecord test works too and
$ ruby -r rubygems -e 'puts Gem.path'
/opt/ruby-enterprise-1.8.6-20080810/lib/ruby/gems/1.8
/var/lib/gems/1.8

which is expected and the obi8 lib is installed there
$ ls -d /opt/ruby-enterprise-1.8.6-20080810/lib/ruby/gems/1.8/gems/
ruby-oci8-1.0.3
/opt/ruby-enterprise-1.8.6-20080810/lib/ruby/gems/1.8/gems/ruby-
oci8-1.0.3

any clue?

-- Mattia

Raimonds Simanovskis

unread,
Dec 15, 2008, 8:41:01 AM12/15/08
to Oracle enhanced adapter for ActiveRecord
1. Do you have just Ruby Enterprise Edition on this computer? No
original MRI? (Just wanted to be sure that there are no conflicts
between different Ruby installations)

2. It seems that there are some issues with oci8 installation if you
got "no such file to load" issue. Have you compiled and installed ruby-
oci8 library or have you installed it with "gem install ruby-oci8"?
If you have installed as gem then try
require ‘rubygems’
gem ‘ruby-oci8’
require 'oci8'
OCI8.new('user', 'password', 'database').exec('select * from dual') do
|r| puts r.join(','); end

if successful it should return X from this select.

2. Is activerecord-oracle_enhanced-adapter installed?
gem list activerecord-oracle_enhanced-adapter

3. Verify that activerecord-oracle_enhanced-adapter is working from
irb:

require ‘rubygems’
gem ‘activerecord’
gem ‘activerecord-oracle_enhanced-adapter’
require ‘activerecord’
ActiveRecord::Base.establish_connection(:adapter => “oracle_enhanced”,
:database => “database”,:username => “user”,:password => “password”)

and see if it is successful (use your correct database, username and
password)

As I understand your previous post is related to the same issue?

Raimonds

Mattia

unread,
Dec 16, 2008, 1:50:20 AM12/16/08
to Oracle enhanced adapter for ActiveRecord
Hi Ray,

thanks for your time. See below for all the answers.

On Dec 15, 10:41 pm, Raimonds Simanovskis
<raimonds.simanovs...@gmail.com> wrote:
> 1. Do you have just Ruby Enterprise Edition on this computer? No
> original MRI? (Just wanted to be sure that there are no conflicts
> between different Ruby installations)

I thought this could be the problem. I had ruby-1.8 and ruby-1.9
installed but removed them and the problem still persists.

> 2. It seems that there are some issues with oci8 installation if you
> got "no such file to load" issue. Have you compiled and installed ruby-
> oci8 library or have you installed it with "gem install ruby-oci8"?
> If you have installed as gem then try
> require ‘rubygems’
> gem ‘ruby-oci8’
> require 'oci8'
> OCI8.new('user', 'password', 'database').exec('select * from dual') do
> |r| puts r.join(','); end
>
> if successful it sho1uld return X from this select.

$ /opt/ruby/bin/ruby <<EOF
require 'rubygems'
gem 'ruby-oci8'
require 'oci8'
OCI8.new('u', 'p', 'db').exec('select * from dual') do |r| puts r.join
(','); end
EOF
X

> 2. Is activerecord-oracle_enhanced-adapter installed?
> gem list activerecord-oracle_enhanced-adapter

yes, it's there:
activerecord-oracle_enhanced-adapter (1.1.8)

> 3. Verify that activerecord-oracle_enhanced-adapter is working from
> irb:
>
> require ‘rubygems’
> gem ‘activerecord’
> gem ‘activerecord-oracle_enhanced-adapter’
> require ‘activerecord’
> ActiveRecord::Base.establish_connection(:adapter => “oracle_enhanced”,
> :database => “database”,:username => “user”,:password => “password”)

$ /opt/ruby/bin/irb
>> require 'rubygems'
=> false
>> gem 'activerecord'
=> true
>> gem 'activerecord-oracle_enhanced-adapter'
=> true
>> require 'activerecord'
=> true
>> ActiveRecord::Base.establish_connection(:adapter => "oracle_enhanced", :database => "db", :username => "u", :password => "p")
=> #<ActiveRecord::Base::ConnectionSpecification:0x99518f8
@adapter_method="oracle_enhanced_connection", @config=
{:database=>"db", :username=>"u", :adapter=>"oracle_enhanced", :password=>"p"}
>> class Tester < ActiveRecord::Base
>> set_table_name('dual')
>> end
=> nil
>> Tester.find_by_sql('select sysdate as d from dual')[0].d
=> Tue Dec 16 15:44:42 0900 2008

> and see if it is successful (use your correct database, username and
> password)
>
> As I understand your previous post is related to the same issue?

not really (as far as I understand), Rails was complaining about that.
To work it around I installed the gem in the Rails tree (using rails
2.2.0 and rake gems:install) and added the definition as outlined in
my previous post.

Thanks
-- mattia

Raimonds Simanovskis

unread,
Dec 16, 2008, 5:59:09 AM12/16/08
to Oracle enhanced adapter for ActiveRecord
OK, so it seems that all the components (ruby-oci8 and
oracle_enahnced) are working.

Then the question about your environment.rb. I use the following line
there:
config.gem "activerecord-oracle_enhanced-adapter", :lib =>
"active_record/connection_adapters/oracle_enhanced_adapter"

Do you use it in the same way?

In addition I am also using ruby-plsql gem and have the following line
in environment.rb:
config.gem "ruby-plsql", :lib => "ruby_plsql"

oracle_enhanced tries to require ruby-plsql library as well but if it
is missing then it should work also without it.
But maybe you can try to install ruby-plsql gem as well and include it
in your environment.rb file.

Raimonds

theturingmachine

unread,
Dec 16, 2008, 1:46:07 PM12/16/08
to Oracle enhanced adapter for ActiveRecord
When using the oracle_enhanced adapter with REE, I've had to install
both the ruby-oci8 library and the gem to get it to work.
Also if you want to use it with passenger, then you'll need pass the
LD_LIBRARY_PATH to passenger, since it doesn't take it from the
environment, there's a lil' hack I've found somewhere, I just don't
have it right now. Let me know if you need it, so I search for it.

On Dec 16, 11:59 am, Raimonds Simanovskis

Raimonds Simanovskis

unread,
Dec 16, 2008, 2:08:42 PM12/16/08
to Oracle enhanced adapter for ActiveRecord
I also just found that the issue is that Passenger starts with very
few environment variables and actually ruby-oci8 library cannot be
load because of missing LD_LIBRARY_PATH environment variable.

Try to put in environment.rb
require "oci8"
before
config.gem "activerecord-oracle_enhanced-adapter", ...
to verify if you can load oci8 library.

One workaround for setting environment variables for Passenger I wrote
in my blog post
http://blog.rayapps.com/2008/05/21/using-mod_rails-with-rails-applications-on-oracle/

Recently I found that you can also use envvars file for setting Apache
environment variables but somehow it does not work anymore on my Mac
(the file is /usr/sbin/envvars and it is executed in apachectl
script). If anyone knows what could be the issue I would like to hear
it.

There is currently issue registered in Passenger issue register about
supporting SetEnv Apache configuration directive but currently it is
not yet implemented:
http://code.google.com/p/phusion-passenger/issues/detail?id=81

Raimonds

On Dec 16, 8:46 pm, theturingmachine <theturingmach...@gmail.com>
wrote:

Raimonds Simanovskis

unread,
Dec 16, 2008, 2:46:03 PM12/16/08
to Oracle enhanced adapter for ActiveRecord
I found how to correctly add environment variables to Apache httpd
process in Mac OS X 10.5.
Edit /System/Library/LaunchDaemons/org.apache.httpd.plist
and add the following lines after <dict> line:

<key>EnvironmentVariables</key>
<dict>
<key>DYLD_LIBRARY_PATH</key>
<string>/usr/local/oracle/instantclient_10_2:/usr/lib</string>
<key>NLS_LANG</key>
<string>AMERICAN_AMERICA.UTF8</string>
<key>TNS_ADMIN</key>
<string>/usr/local/oracle/network/admin</string>
</dict>

Adjust environment variables according to your Oracle Instant Client
location.

On Linux it seems that you should use envvars file to set up Apache
environment variables. Look in your apachectl (or apache2ctl) script
where it is looking for envvars file.

Raimonds

On Dec 16, 9:08 pm, Raimonds Simanovskis
<raimonds.simanovs...@gmail.com> wrote:
> I also just found that the issue is that Passenger starts with very
> few environment variables and actually ruby-oci8 library cannot be
> load because of missing LD_LIBRARY_PATH environment variable.
>
> Try to put in environment.rb
> require "oci8"
> before
> config.gem "activerecord-oracle_enhanced-adapter", ...
> to verify if you can load oci8 library.
>
> One workaround for setting environment variables for Passenger I wrote
> in my blog posthttp://blog.rayapps.com/2008/05/21/using-mod_rails-with-rails-applica...

Mattia

unread,
Dec 16, 2008, 6:56:50 PM12/16/08
to Oracle enhanced adapter for ActiveRecord
On Dec 16, 7:59 pm, Raimonds Simanovskis
<raimonds.simanovs...@gmail.com> wrote:
> OK, so it seems that all the components (ruby-oci8 and
> oracle_enahnced) are working.
>
> Then the question about your environment.rb. I use the following line
> there:
> config.gem "activerecord-oracle_enhanced-adapter", :lib =>
> "active_record/connection_adapters/oracle_enhanced_adapter"

this did it! my bad for not looking more carefully at the :lib option.

> In addition I am also using ruby-plsql gem and have the following line
> in environment.rb:
> config.gem "ruby-plsql", :lib => "ruby_plsql"
>
> oracle_enhanced tries to require ruby-plsql library as well but if it
> is missing then it should work also without it.
> But maybe you can try to install ruby-plsql gem as well and include it
> in your environment.rb file.

I don't have ruby-plsql and as expected ruby-oci8 is doing just fine.

Thanks
-- mattia

Mattia

unread,
Dec 16, 2008, 7:02:17 PM12/16/08
to Oracle enhanced adapter for ActiveRecord
On Dec 17, 4:08 am, Raimonds Simanovskis
<raimonds.simanovs...@gmail.com> wrote:
...
> Recently I found that you can also use envvars file for setting Apache
> environment variables but somehow it does not work anymore on my Mac
> (the file is /usr/sbin/envvars and it is executed in apachectl
> script). If anyone knows what could be the issue I would like to hear
> it.

Just for the record, Debian has /etc/apache2/envvars which is sourced
in all the apache system scripts

-- mattia
Reply all
Reply to author
Forward
0 new messages