# Script throws error whenever I require mysql gem

**URL:** <https://www.ruby-forum.com/t/script-throws-error-whenever-i-require-mysql-gem/163696>\
**Category:** Ruby\
**Created:** [March 24, 2009, 2:09am UTC](https://www.ruby-forum.com/t/script-throws-error-whenever-i-require-mysql-gem/163696 "2009-03-24T02:09:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [March 24, 2009, 2:09am UTC](https://www.ruby-forum.com/t/script-throws-error-whenever-i-require-mysql-gem/163696/1 "2009-03-24T02:09:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [March 24, 2009, 5:24pm UTC](https://www.ruby-forum.com/t/script-throws-error-whenever-i-require-mysql-gem/163696/2 "2009-03-24T17:24:54Z")

</div>

On Tue, Mar 24, 2009 at 6:36 AM, Chris G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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](http://rubyurl.com/B4Kl)

cheers,  
lasitha.

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [March 25, 2009, 12:45am UTC](https://www.ruby-forum.com/t/script-throws-error-whenever-i-require-mysql-gem/163696/3 "2009-03-25T00:45:55Z")

</div>

Hi,

Just ran through all of those steps and still no luck. the exact same  
error is being thrown. Cant seem to get through this error at all!

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [March 25, 2009, 2:30am UTC](https://www.ruby-forum.com/t/script-throws-error-whenever-i-require-mysql-gem/163696/4 "2009-03-25T02:30:32Z")

</div>

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
