# Require mysql do not work

**URL:** <https://www.ruby-forum.com/t/require-mysql-do-not-work/139987>\
**Category:** Ruby\
**Created:** [June 9, 2008, 8:41pm UTC](https://www.ruby-forum.com/t/require-mysql-do-not-work/139987 "2008-06-09T20:41:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 9, 2008, 8:41pm UTC](https://www.ruby-forum.com/t/require-mysql-do-not-work/139987/1 "2008-06-09T20:41:36Z")

</div>

Hello guys,

I am new to Ruby. I have been working with the core language so far  
without problems. Now I am starting to use mysql.

I have installed it with gem install mysql, and it work perfectly. If I  
run gem list, I get the following:

sh-3.2# gem list

\*\*\* LOCAL GEMS \*\*\*

actionmailer (2.1.0, 1.3.6)  
actionpack (2.1.0, 1.13.6)  
actionwebservice (1.2.6)  
activerecord (2.1.0, 1.15.6)  
activeresource (2.1.0)  
activesupport (2.1.0, 1.4.4)  
acts\_as\_ferret (0.4.3, 0.4.1)  
capistrano (2.3.0, 2.0.0)  
cgi\_multipart\_eof\_fix (2.5.0, 2.2)  
daemons (1.0.10, 1.0.9, 1.0.7)  
dnssd (0.6.0)  
fastthread (1.0.1, 1.0)  
fcgi (0.8.7)  
ferret (0.11.6, 0.11.4)  
gem\_plugin (0.2.3, 0.2.2)  
highline (1.4.0, 1.2.9)  
hpricot (0.6)  
libxml-ruby (0.5.4, 0.3.8.4)  
mongrel (1.1.5, 1.1.4, 1.0.1)  
mysql (2.7)  
needle (1.3.0)  
net-scp (1.0.1)  
net-sftp (2.0.1, 1.1.0)  
net-ssh (2.0.2, 1.1.2)  
net-ssh-gateway (1.0.0)  
rails (2.1.0, 1.2.6)  
rake (0.8.1, 0.7.3)  
RedCloth (3.0.4)  
ruby-openid (2.0.4, 1.1.4)  
ruby-yadis (0.3.4)  
rubygems-update (1.1.1)  
rubynode (0.1.5, 0.1.3)  
sqlite3-ruby (1.2.2, 1.2.1)  
termios (0.9.4)

As you can see mysql 2.7 is installed. When I put the line require  
“mysql”  
in the first line of my program, I get the following error:

sh-3.2# ruby learn.rb  
learn.rb:1:in `require’: no such file to load – mysql (LoadError)  
from learn.rb:1

I am on Mac OS X 10.5.3 with Ruby 1.8.6, and the outputs included in the  
email have been generated with “root”. Any ideas why it is not working?

Thanks,

Guillermo

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 9, 2008, 9:23pm UTC](https://www.ruby-forum.com/t/require-mysql-do-not-work/139987/2 "2008-06-09T21:23:59Z")

</div>

On Jun 9, 8:38 pm, removed\_email\_address@domain.invalid wrote:

> sh-3.2# gem list  
> capistrano (2.3.0, 2.0.0)  
> mongrel (1.1.5, 1.1.4, 1.0.1)  
> ruby-yadis (0.3.4)  
> from learn.rb:1
> 
> I am on Mac OS X 10.5.3 with Ruby 1.8.6, and the outputs included in the  
> email have been generated with “root”. Any ideas why it is not working?

try this:

require ‘rubygems’  
require ‘mysql’

mysql being installed as gem require you first load rubygems to work  
(unless you have RUBYOPT=rubygems which is not your case).

HTH,

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 9, 2008, 10:18pm UTC](https://www.ruby-forum.com/t/require-mysql-do-not-work/139987/3 "2008-06-09T22:18:06Z")

</div>

Thank you Luis.

It worked!

Guillermo

From:  
Luis L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To:  
removed\_email\_address@domain.invalid (ruby-talk ML)  
Date:  
09.06.2008 21:25  
Subject:  
Re: require mysql do not work

On Jun 9, 8:38 pm, removed\_email\_address@domain.invalid wrote:

> sh-3.2# gem list  
> capistrano (2.3.0, 2.0.0)  
> mongrel (1.1.5, 1.1.4, 1.0.1)  
> ruby-yadis (0.3.4)  
> rubygems-update (1.1.1)  
> rubynode (0.1.5, 0.1.3)  
> sqlite3-ruby (1.2.2, 1.2.1)  
> termios (0.9.4)
> 
> As you can see mysql 2.7 is installed. When I put the line require  
> “mysql”  
> in the first line of my program, I get the following error:
> 
> sh-3.2# ruby learn.rb  
> learn.rb:1:in `require’: no such file to load – mysql (LoadError)  
> from learn.rb:1
> 
> I am on Mac OS X 10.5.3 with Ruby 1.8.6, and the outputs included in the  
> email have been generated with “root”. Any ideas why it is not working?

try this:

require ‘rubygems’  
require ‘mysql’

mysql being installed as gem require you first load rubygems to work  
(unless you have RUBYOPT=rubygems which is not your case).

HTH,
