Script throws error whenever I require mysql gem

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 :slight_smile:

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/.

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

cheers,
lasitha.

路路路

On Tue, Mar 24, 2009 at 6:36 AM, Chris Gallagher <cgallagher@gmail.com> 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

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/.