Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Trouble with require statements and MySQL Adapter

#11

Using v.0.8.0 in a standalone ruby (not rails) context:


require 'ar-extensions/adapters/mysql'
require 'ar-extensions/import/mysql'

produces the following error:


/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:276:in `load_missing_constant': uninitialized constant ActiveRecord::ConnectionAdapters::MysqlAdapter (NameError)
        from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:468:in `const_missing'
        from /usr/local/lib/rubygems/gems/gems/ar-extensions-0.8.0/lib/ar-extensions/adapters/mysql.rb:1
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:510:in `require'
        from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:355:in `new_constants_in'
        from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:510:in `require'

Gems installed include: activerecord, activeresource, activesupport, ar-extensions, mysql, rails

Reported by Karsten · November 18th, 2008 @ 01:42 PM

State: new
Milestone: none
Assigned to: nobody

Activity

  1. Joe None
    Joe None

    I'm also having the same issue, but in a rails context

    March 18th, 2009 @ 01:41 AM

  2. Zach Dennis
    Zach Dennis

    Karsten / joe, sorry about the late response. I didn't have myself as the default assigned user so I wasn't getting emailed by Lighthouse about the ticket.

    Did you find a way around your issue? If you can still reproduce would you mind installing the newest 0.9.1 gem and seeing if the problem exists?

    April 21st, 2009 @ 01:01 PM

  3. Zach Dennis
    Zach Dennis

    Karsten / joe, sorry about the late response. I didn't have myself as the default assigned user so I wasn't getting emailed by Lighthouse about the ticket.

    Did you find a way around your issue? If you can still reproduce would you mind installing the newest 0.9.1 gem and seeing if the problem exists?

    April 21st, 2009 @ 01:02 PM

  4. p-daddy
    p-daddy

    Having same problem with require statements

    I've upgraded to 0.9.1

    these are some of my gems

    actionmailer (2.3.2) actionpack (2.3.2) actionwebservice (1.2.6) activemerchant (1.4.2) activerecord (2.3.2) activeresource (2.3.2) activesupport (2.3.2) ar-extensions (0.9.1) archive-tar-minitar (0.5.2) arrayfields (4.7.3) attributes (5.0.1) aws-s3 (0.6.2)

    here's a bit of the trace irb irb(main):001:0> require 'rubygems' => true irb(main):002:0> require 'mysql' => true irb(main):003:0> require 'activerecord' => true irb(main):004:0> require 'date' => [] irb(main):005:0> require 'fastercsv' => [] irb(main):006:0> require 'ftools' => [] irb(main):007:0> require 'facets' => [] irb(main):008:0> require 'yaml' => [] irb(main):009:0> require 'ar-extensions' => [] irb(main):010:0> require 'ar-extensions/import/mysql' NameError: uninitialized constant ActiveRecord::ConnectionAdapters::MysqlAdapter

    from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:440:in `load_missing_constant'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing'
    from /usr/lib/ruby/gems/1.8/gems/ar-extensions-0.9.1/lib/ar-extensions/import/mysql.rb:48
    from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
    from (irb):10
    
    

    irb(main):011:0> require 'ar-extensions/adapters/mysql' irb(main):011:0> require 'ar-extensions/adapters/mysql' NameError: uninitialized constant ActiveRecord::ConnectionAdapters::MysqlAdapter

    from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:440:in `load_missing_constant'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing'
    from /usr/lib/ruby/gems/1.8/gems/ar-extensions-0.9.1/lib/ar-extensions/adapters/mysql.rb:1
    from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
    from (irb):11
    
    

    irb(main):012:0>

    May 12th, 2009 @ 11:05 AM

  5. Jean-Baptiste Feldis
    Jean-Baptiste Feldis

    Hello guys,

    got the same problem, resolved by adding a:
    "require 'ar-extensions'"

    before the 2 other ones.

    May 13th, 2009 @ 07:20 AM

  6. Thurston
    Thurston

    Thanks, Jean.

    Your advice works, further more, I have to remove that two requires, otherwise still got 'uninitialized constant' issues, seems 0.9.1 is not neccessary to declare adapter...

    May 16th, 2009 @ 12:03 PM

  7. charlesparnot
    charlesparnot

    I had the same issue with 0.9.2 and running within Rails 2.3.2.

    If I only use "require 'ar-extensions'", no error. If I don't add explicitely the import module for SQLite, it does not do the fast import. So I added "require 'ar-extensions/import/sqlite'". That worked fine, no error.

    The error message was specifically after adding "require 'ar-extensions/import/mysql'" (or "require 'ar-extensions/adapters/mysql'").

    Removing the "require 'ar-extensions/import/mysql'" makes the message go away. But then I am afraid it is not going to have the optimised import running, cf http://www.continuousthinking.com/2008/8/16/ar-extensions-0-8-0-for.... So, Thurston, I am afraid you may have removed the error messages, but not sure you have the functionality you want.

    The way to fix all of this is to add this line to your config/environment.rb in the "Rails::Initializer.run" block:

    config.gem "activerecord"

    After this, you don't even need "require 'ar-extensions'".

    I have no idea where the whole thing comes from, too much gem voodoo loading going on :-)

    September 18th, 2009 @ 01:12 PM

  8. bruce
    bruce
    • Assigned user cleared.

    I installed ar-extensions for the first time today, and in attempting to use on_duplicate_key_update in a rake task I ran smack into this problem.

    I'm using 0.9.2 with Rails 2.3.4.

    When installing the gem, activesupport 2.3.5 was also installed (Rails 2.3.5 was released yesterday). This has nothing to do with it.

    I tried everything in this thread and nothing worked. Keeping in mind something I read somewhere about not being afraid to look at the source, I came upon this at the end of gems/ar-extensions-0.9.2/init.rb:

    #load all available functionality for specified adapter
    # Ex. ENV['LOAD_ADAPTER_EXTENSIONS'] = 'mysql'
    if ENV['LOAD_ADAPTER_EXTENSIONS']
      require "active_record/connection_adapters/#{ENV['LOAD_ADAPTER_EXTENSIONS']}_adapter.rb"
      file_regexp = File.join(File.dirname(__FILE__), 'lib', 'ar-extensions','**',
                              "#{ENV['LOAD_ADAPTER_EXTENSIONS']}.rb")
                            
      Dir.glob(file_regexp){|file| require(file) }
    end
    

    After putting ENV['LOAD_ADAPTER_EXTENSIONS'] = 'mysql' at the top of the rake file before the requires, it worked perfectly.

    December 1st, 2009 @ 01:37 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.