# Require 'mysql' is failing

**URL:** <https://www.ruby-forum.com/t/require-mysql-is-failing/101886>\
**Category:** Ruby\
**Created:** [August 8, 2006, 4:12pm UTC](https://www.ruby-forum.com/t/require-mysql-is-failing/101886 "2006-08-08T16:12:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [August 8, 2006, 4:12pm UTC](https://www.ruby-forum.com/t/require-mysql-is-failing/101886/1 "2006-08-08T16:12:23Z")

</div>

I really thought I’d be through at this point … but

Thanks to several of you here (and I _REALLY_ appreciate the help), I  
_FINALLY_ managed to get the mysql gem installed. When I ran gem  
install, it gave me several options, I chose (2) which was for the mysql  
2.7 (ruby) gem (I’m running Ubuntu linux). gem reported that the package  
was successfully installed.

When I run ruby, and have the statement  
require ‘mysql’

ruby gives me the error  
:in `require’: no such file to load – mysql (LoadError)

What am I missing. At this point, I thought I’d done everything right.

thanks again  
—Michael

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [August 8, 2006, 4:17pm UTC](https://www.ruby-forum.com/t/require-mysql-is-failing/101886/2 "2006-08-08T16:17:59Z")

</div>

2006/8/8, Michael S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 

have you tried this?  
require ‘rubygems’  
require\_gem ‘mysql’

> 

–  
Name : Arie Kusuma A., A.K.A Arie, A.K.A ariekeren / YM! = riyari3  
[http://ariekusumaatmaja.wordpress.com](http://ariekusumaatmaja.wordpress.com)  
Let’s build Ruby Indonesia stronger

> **[Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos](https://www.yahoo.com/)**
>
> Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!

Go Go Ruby Go!  
While making love with my PowerBook now i’m happier i’ve got a new  
desktop computer with Linux Fedora Core 5 but unfortunately there’s no  
textmate for linux :((  
how can you mend my broken heart ???

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [August 8, 2006, 5:01pm UTC](https://www.ruby-forum.com/t/require-mysql-is-failing/101886/3 "2006-08-08T17:01:51Z")

</div>

Arie Kusuma A. wrote:

> 2006/8/8, Michael S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > 
> 
> have you tried this?  
> require ‘rubygems’  
> require\_gem ‘mysql’

No I hadn’t; I never saw that construct before (hey! I’m still learning  
here!)

I just did, and it works. This brings up some questions, which I’m  
_REALLY_ hoping that the experts here will educate me on.

Is the require ‘rubygems’ … the correct construct? Is it going to work  
in rails?

Is there a way to get the gem loaded with a simple “require ‘mysql’”?

I’m really trying to learn this so I don’t have to keep bugging the  
people here. I also want to thank all of you for the help you’ve given.  
I appreciate this community more than you know.

—Michael

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [August 8, 2006, 5:18pm UTC](https://www.ruby-forum.com/t/require-mysql-is-failing/101886/4 "2006-08-08T17:18:06Z")

</div>

On Wed, Aug 09, 2006, Michael S. wrote:

> No I hadn’t; I never saw that construct before (hey! I’m still learning  
> here!)
> 
> I just did, and it works. This brings up some questions, which I’m  
> _REALLY_ hoping that the experts here will educate me on.
> 
> Is the require ‘rubygems’ … the correct construct? Is it going to work  
> in rails?

Yes, it’s correct. In order to include a gem, you have to include  
rubygems. You don’t necessarily need to use require\_gem (plain require  
should work so long as you’ve already require’d rubygems) but it can be  
helpful to remember what’s a gem and what isn’t.

As for rails, you shouldn’t need to include it explicitly. I’m not sure  
exactly how it all works internally, but if your database.yml is set up  
to use mysql, it will automatically require the gem. I believe that  
Rails simply require’s whatever the adapter string is, but again, I’m  
not sure.

> Is there a way to get the gem loaded with a simple “require ‘mysql’”?

Sure! Install it from source instead of as a gem 😉

Alternately, you could go into wherever you have Ruby installed  
and write a little wrapper in a mysql.rb file that simply requires  
rubygems and mysql. I’m not really sure how that would work, though, as  
I just tried it and it… didn’t.

Really, though, it’s not that bad to just require rubygems, is it? 😉

> I’m really trying to learn this so I don’t have to keep bugging the  
> people here. I also want to thank all of you for the help you’ve given.  
> I appreciate this community more than you know.

Everyone starts somewhere 🙂 The Ruby community is the nicest I’ve ever  
known. Bring your questions, they’re always welcome and someone will  
answer.

Ben

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [August 8, 2006, 5:24pm UTC](https://www.ruby-forum.com/t/require-mysql-is-failing/101886/5 "2006-08-08T17:24:20Z")

</div>

OK, Ben. You’re another one I owe a lunch if you’re ever in the area of  
Houston, TX.

Ben B. wrote:

> > Is the require ‘rubygems’ … the correct construct? Is it going to work  
> > in rails?
> 
> Yes, it’s correct. In order to include a gem, you have to include  
> rubygems. You don’t necessarily need to use require\_gem (plain require  
> should work so long as you’ve already require’d rubygems) but it can be  
> helpful to remember what’s a gem and what isn’t.
> 
> As for rails, you shouldn’t need to include it explicitly. I’m not sure  
> exactly how it all works internally, but if your database.yml is set up  
> to use mysql, it will automatically require the gem. I believe that  
> Rails simply require’s whatever the adapter string is, but again, I’m  
> not sure.

OK, things are falling into place now. Thanks.

> Really, though, it’s not that bad to just require rubygems, is it? 😉

Not at all - now that I realize I need to.

> > I’m really trying to learn this so I don’t have to keep bugging the  
> > people here. I also want to thank all of you for the help you’ve given.  
> > I appreciate this community more than you know.
> 
> Everyone starts somewhere 🙂 The Ruby community is the nicest I’ve ever  
> known. Bring your questions, they’re always welcome and someone will  
> answer.

And I want to thank you - and everyone else here. You’ve got me past  
some major hurdles. I appreciate it much.

—Michael
