require 'mysql' is failing

  • Thread starter Michael Satterwhite
  • Start date
M

Michael Satterwhite

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
 
A

Arie Kusuma Atmaja

2006/8/8 said:
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'

have you tried this?
require 'rubygems'
require_gem '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


--
Name : Arie Kusuma Atmaja, A.K.A Arie, A.K.A ariekeren / YM! = riyari3
http://ariekusumaatmaja.wordpress.com
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 ????
 
M

Michael Satterwhite

Arie said:
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
 
B

Ben Bleything

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
 
M

Michael Satterwhite

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

Ben said:
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? ;)


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top