Require 'mysql' is failing

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

2006/8/8, Michael S. [email protected]:

have you tried this?
require ‘rubygems’
require_gem ‘mysql’


Name : Arie Kusuma A., A.K.A Arie, A.K.A ariekeren / YM! = riyari3


Let’s build Ruby Indonesia stronger
http://groups.yahoo.com/groups/id-ruby

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 ???

Arie Kusuma A. wrote:

2006/8/8, Michael S. [email protected]:

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

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

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? :wink:

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 :slight_smile: The Ruby community is the nicest I’ve ever
known. Bring your questions, they’re always welcome and someone will
answer.

Ben

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? :wink:

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs