# Locomotive: Can not install mysql gem

**URL:** <https://www.ruby-forum.com/t/locomotive-can-not-install-mysql-gem/121648>\
**Category:** Rails\
**Created:** [November 29, 2007, 5:10pm UTC](https://www.ruby-forum.com/t/locomotive-can-not-install-mysql-gem/121648 "2007-11-29T17:10:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@ronny](https://www.ruby-forum.com/u/ronny)\
**Post date:** [November 29, 2007, 5:10pm UTC](https://www.ruby-forum.com/t/locomotive-can-not-install-mysql-gem/121648/1 "2007-11-29T17:10:34Z")

</div>

I’m using Locomotive on MacOSX 10.4, and I have installed mysql  
5.0.45.

To my surprise, the Ruby version included in Locomotive does not come  
with the mysql  
gem installed, so I tried to install it manually. According to the  
instructions in database.yml,  
this should be done using the --include switch, like this:

gem install mysql – --include=/usr/local/lib

I selected the mysql 2.7 (ruby) version of the gem, but got the build  
error listed below. What can I do to get the mysql gem installed?

Ronald

Error Message:

Building native extensions. This could take a while…  
ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)  
ERROR: Failed to build gem native extension.

ruby extconf.rb install mysql – --include=/usr/local/lib  
checking for mysql\_query() in -lmysqlclient… no  
checking for main() in -lm… no  
checking for mysql\_query() in -lmysqlclient… no  
checking for main() in -lz… no  
checking for mysql\_query() in -lmysqlclient… no  
checking for main() in -lsocket… no  
checking for mysql\_query() in -lmysqlclient… no  
checking for main() in -lnsl… no  
checking for mysql\_query() in -lmysqlclient… no  
\*\*\* extconf.rb failed \*\*\*  
Could not create Makefile due to some reason, probably lack of  
necessary libraries and/or headers. Check the mkmf.log file for more  
details. You may need configuration options.

---

<div class="post-metadata">

**Author:** ![ronny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@ronny](https://www.ruby-forum.com/u/ronny)\
**Post date:** [November 29, 2007, 5:21pm UTC](https://www.ruby-forum.com/t/locomotive-can-not-install-mysql-gem/121648/2 "2007-11-29T17:21:07Z")

</div>

On Nov 29, 2007, at 10:10 AM, Ronny wrote:

> I’m using Locomotive on MacOSX 10.4, and I have installed mysql  
> 5.0.45.
> 
> To my surprise, the Ruby version included in Locomotive does not come  
> with the mysql  
> gem installed, so I tried to install it manually.

I had no problems with using locomotive and MySQL. I did nothing  
special at all.  
I installed Locomotive, edited database.yml, and was good to go. Apart  
from the download the whole thing took maybe two minutes.

Maybe the problem is the MySQL installation? If you’re using  
Locomotive, why not use MAMP as well? That will give you a pain-free  
self-contained MySQL server. to move it or back it up, just copy the  
folder.

---

<div class="post-metadata">

**Author:** ![ronny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@ronny](https://www.ruby-forum.com/u/ronny)\
**Post date:** [November 30, 2007, 8:19am UTC](https://www.ruby-forum.com/t/locomotive-can-not-install-mysql-gem/121648/3 "2007-11-30T08:19:06Z")

</div>

On Nov 29, 5:20 pm, George B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> special at all.  
> So when you do a

gem list

you can see a mysql gem? Which version of the gem do you see?

> Maybe the problem is the MySQL installation?

I don’t know. I installed it straight from the MySql website - the  
version for the Mac.  
Do I have any additional packages to install from there?

> If you’re using  
> Locomotive, why not use MAMP as well? That will give you a pain-free  
> self-contained MySQL server. to move it or back it up, just copy the  
> folder.

Never heard of MAMP before. Tried to google to it, and found a few  
references  
pointing to [http://www.mamp.com/](http://www.mamp.com/) , but this page seems to be only a  
search  
site for programming topics. Could you give me a link?

Ronald

---

<div class="post-metadata">

**Author:** ![ronny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@ronny](https://www.ruby-forum.com/u/ronny)\
**Post date:** [December 1, 2007, 4:52pm UTC](https://www.ruby-forum.com/t/locomotive-can-not-install-mysql-gem/121648/4 "2007-12-01T16:52:38Z")

</div>

> I had no problems with using locomotive and MySQL. I did nothing  
> special at all.

This was also confirmed by a friend. Actually, I didn’t _try_ to use  
it  
“as it comes out of the box” (and, for sure, I should have tried  
before  
posting), because from my experience with a non-rails Ruby project,  
I knew that back then I _had_ to install the mysql gem, so when I  
checked the list of the installed gems and found mysql missing, I was  
absolutely sure that I had to manually install it.

Now if a kind soul just could explain to me why RoR works with MySql  
without the mysql gem being installed…

Ronald

---

<div class="post-metadata">

**Author:** ![ronny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@ronny](https://www.ruby-forum.com/u/ronny)\
**Post date:** [December 8, 2007, 11:22am UTC](https://www.ruby-forum.com/t/locomotive-can-not-install-mysql-gem/121648/5 "2007-12-08T11:22:24Z")

</div>

On Dec 1, 5:19 pm, William P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It works because rails ships with the pure ruby mysql bindings in case  
> you don’t have the gem installed.

… and the pure version is obviously not installed as a Gem. Thank  
you  
for explaining.

Ronald

---

<div class="post-metadata">

**Author:** ![ronny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@ronny](https://www.ruby-forum.com/u/ronny)\
**Post date:** [December 1, 2007, 5:20pm UTC](https://www.ruby-forum.com/t/locomotive-can-not-install-mysql-gem/121648/6 "2007-12-01T17:20:44Z")

</div>

It works because rails ships with the pure ruby mysql bindings in case  
you don’t have the gem installed. The only benefit to the C bindings  
version (the other gem) is speed as it is quite a bit faster than the  
pure ruby version.

-Bill

---

<div class="post-metadata">

**Author:** ![ronny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@ronny](https://www.ruby-forum.com/u/ronny)\
**Post date:** [February 8, 2009, 1:21pm UTC](https://www.ruby-forum.com/t/locomotive-can-not-install-mysql-gem/121648/7 "2009-02-08T13:21:16Z")

</div>

Hi,

I got the same problem, did you alredy resolved it?

Regrds,  
Ed

Ronny wrote:

> I’m using Locomotive on MacOSX 10.4, and I have installed mysql  
> 5.0.45.
> 
> To my surprise, the Ruby version included in Locomotive does not come  
> with the mysql  
> gem installed, so I tried to install it manually. According to the  
> instructions in database.yml,  
> this should be done using the --include switch, like this:
> 
> gem install mysql – --include=/usr/local/lib
> 
> I selected the mysql 2.7 (ruby) version of the gem, but got the build  
> error listed below. What can I do to get the mysql gem installed?
> 
> Ronald
> 
> Error Message:
> 
> Building native extensions. This could take a while…  
> ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)  
> ERROR: Failed to build gem native extension.
> 
> ruby extconf.rb install mysql – --include=/usr/local/lib  
> checking for mysql\_query() in -lmysqlclient… no  
> checking for main() in -lm… no  
> checking for mysql\_query() in -lmysqlclient… no  
> checking for main() in -lz… no  
> checking for mysql\_query() in -lmysqlclient… no  
> checking for main() in -lsocket… no  
> checking for mysql\_query() in -lmysqlclient… no  
> checking for main() in -lnsl… no  
> checking for mysql\_query() in -lmysqlclient… no  
> \*\*\* extconf.rb failed \*\*\*  
> Could not create Makefile due to some reason, probably lack of  
> necessary libraries and/or headers. Check the mkmf.log file for more  
> details. You may need configuration options.
