Script throws error whenever I require mysql gem

Discussion in 'Ruby' started by Chris Gallagher, Mar 24, 2009.

  1. Hi all,

    Ive been working on a small script and Im about to place some
    functionality into it which allows it to write to my database by making
    use of activerecord. I'm hitting a brick wall at the moment so I've come
    to you for your expertise :)

    The script runs perfectly fine until i...

    require 'mysql'

    ..even though I havent actually asked the script to do anything more
    than connect to mysql. if i comment out the configure block the error
    still occurs.

    I thought mysql was the issue so i completely reinstalled it from source
    and the same error still occurs.

    heres the error im seeing on Mac OS X Tiger:

    /usr/local/lib/ruby/site_ruby/1.8/i686-darwin8.9.1/mysql.bundle: Failed
    to lookup Init function
    /usr/local/lib/ruby/site_ruby/1.8/i686-darwin8.9.1/mysql.bundle
    (LoadError)
    from
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
    `require'
    from
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in
    `require'
    from
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in
    `new_constants_in'
    from
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in
    `require'
    from bot.rb:6
    /usr/local/lib/ruby/site_ruby/1.8/i686-darwin8.9.1/mysql.bundle: Failed
    to lookup Init function
    /usr/local/lib/ruby/site_ruby/1.8/i686-darwin8.9.1/mysql.bundle
    (LoadError)
    from
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
    `require'
    from
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in
    `require'
    from
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in
    `new_constants_in'
    from
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in
    `require'
    from bot.rb:6
    /usr/local/lib/ruby/site_ruby/1.8/i686-darwin8.9.1/mysql.bundle: Failed
    to lookup Init function
    /usr/local/lib/ruby/site_ruby/1.8/i686-darwin8.9.1/mysql.bundle
    (LoadError)
    from
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
    `require'
    from
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in
    `require'
    from
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in
    `new_constants_in'
    from
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in
    `require'
    from bot.rb:6
    cgallagher:~/work/tuneme/bot chrisgallagher$



    The script for anyone interested is simply as follows:

    require 'rubygems'
    require 'sinatra'
    require 'scrobbler'
    require 'twibot'
    require 'activerecord'
    require 'mysql'

    #startup tasks
    configure do
    #connect to database
    ActiveRecord::Base.establish_connection({
    :adapter => "mysql",
    :database => "tuneme",
    :socket => "/tmp/mysql.socket",
    :username => "root",
    :password => ""
    })
    end

    class Link < ActiveRecord::Base
    end


    reply do |message, params|


    #create entry test
    # link = Link.create:)LinkValue => '123xyz')


    #check last.fm for a recomendation
    message_content = message.text
    artist_name = message_content.gsub("@tuneme ", "")
    p artist_name
    artist = Scrobbler::Artist.new(artist_name)
    #artist.similar.each { |a| puts "(#{a.match}%) #{a.name}" }
    similar_artist = artist.similar.first.name
    message = "@" + message.user.screen_name + " #{similar_artist} and
    others... "
    post_tweet message
    end




    I'm completely at a loss here... any ideas?

    Cheers
    Chris
    --
    Posted via http://www.ruby-forum.com/.
    Chris Gallagher, Mar 24, 2009
    #1
    1. Advertising

  2. Chris Gallagher

    lasitha Guest

    On Tue, Mar 24, 2009 at 6:36 AM, Chris Gallagher <> wrote:
    > [...]
    >
    > The script runs perfectly fine until i...
    >
    > require 'mysql'
    >
    > [...]
    >
    > /usr/local/lib/ruby/site_ruby/1.8/i686-darwin8.9.1/mysql.bundle: Failed
    > to lookup Init function


    The following post is probably still relevant:
    http://rubyurl.com/B4Kl

    cheers,
    lasitha.
    lasitha, Mar 24, 2009
    #2
    1. Advertising

  3. OK, I've now done a complete uninstall and reinstalled with macports
    instead. Now I'm seeing the following error:

    LoadError: Failed to lookup Init function
    /usr/local/lib/ruby/site_ruby/1.8/i686-darwin8.9.1/mysql.bundle
    --
    Posted via http://www.ruby-forum.com/.
    Chris Gallagher, Mar 25, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James Harris
    Replies:
    141
    Views:
    2,566
    Chris Smith
    Feb 24, 2007
  2. Arthur J. O'Dwyer
    Replies:
    16
    Views:
    548
    Chris Smith
    Feb 21, 2007
  3. Michael Glaesemann

    gem query finds gem, yet require fails

    Michael Glaesemann, Nov 12, 2006, in forum: Ruby
    Replies:
    5
    Views:
    152
    Michael Glaesemann
    Nov 26, 2006
  4. Austin 7873
    Replies:
    5
    Views:
    185
    Eric Hodel
    Jan 27, 2007
  5. Daniel Berger
    Replies:
    2
    Views:
    155
    Daniel Berger
    Sep 12, 2008
Loading...

Share This Page