# Mysql gem problems

**URL:** <https://www.ruby-forum.com/t/mysql-gem-problems/203351>\
**Category:** Rails\
**Created:** [February 18, 2011, 8:10am UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351 "2011-02-18T08:10:42Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [February 18, 2011, 8:10am UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/1 "2011-02-18T08:10:42Z")

</div>

I have Xcode 3.0+ installed  
Ruby 1.9.2  
And a direct dmg for mysql

$ sudo gem install mysql – --with-mysql-dir=/usr/local/mysql  
Password:  
Building native extensions. This could take a while…  
ERROR: Error installing mysql:  
ERROR: Failed to build gem native extension.

```
    /usr/local/bin/ruby extconf.rb --with-mysql-dir=/usr/local/mysql

```

checking for mysql\_ssl\_set()… \*\*\* 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.

Provided configuration options:  
–with-opt-dir  
–without-opt-dir  
–with-opt-include  
–without-opt-include=${opt-dir}/include  
–with-opt-lib  
–without-opt-lib=${opt-dir}/lib  
–with-make-prog  
–without-make-prog  
–srcdir=.  
–curdir  
–ruby=/usr/local/bin/ruby  
–with-mysql-config  
–without-mysql-config  
/usr/local/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError) You have to install development tools first. from /usr/local/lib/ruby/1.9.1/mkmf.rb:435:in`try\_link0’  
from /usr/local/lib/ruby/1.9.1/mkmf.rb:440:in `try_link' from /usr/local/lib/ruby/1.9.1/mkmf.rb:552:in`try\_func’  
from /usr/local/lib/ruby/1.9.1/mkmf.rb:797:in `block in have_func' from /usr/local/lib/ruby/1.9.1/mkmf.rb:693:in`block in checking\_for’  
from /usr/local/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone' from /usr/local/lib/ruby/1.9.1/mkmf.rb:254:in`open’  
from /usr/local/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone' from /usr/local/lib/ruby/1.9.1/mkmf.rb:254:in`open’  
from /usr/local/lib/ruby/1.9.1/mkmf.rb:276:in `postpone' from /usr/local/lib/ruby/1.9.1/mkmf.rb:692:in`checking\_for’  
from /usr/local/lib/ruby/1.9.1/mkmf.rb:796:in `have_func' from extconf.rb:50:in`’

Gem files will remain installed in  
/usr/local/lib/ruby/gems/1.9.1/gems/mysql-2.8.1 for inspection.

I really need to fix this problem and i dont have no idea how to

thanks for the help

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 18, 2011, 2:11pm UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/2 "2011-02-18T14:11:03Z")

</div>

if you’re on a mac, get homebrew, then type in your terminal “brew  
install  
mysql”

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 18, 2011, 5:59pm UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/3 "2011-02-18T17:59:59Z")

</div>

Hi,

I think you have to install mysql development stuff first.

In Centos I had the same problem, after i installed mysql-devel, I could  
install mysql without any erros.

Cheers,

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 19, 2011, 12:26am UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/4 "2011-02-19T00:26:28Z")

</div>

where do i find those dev tools?

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 19, 2011, 12:55pm UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/5 "2011-02-19T12:55:14Z")

</div>

I cant seem to find the equivalent of those packages for mac. If someone  
knows the steps for MacOSX i would sureley apreciate it.

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 19, 2011, 3:03pm UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/6 "2011-02-19T15:03:31Z")

</div>

It might be worth leaving a little more context in your postings. I  
don’t know offhand which packages you’re looking for as I’m just  
“checking in” on the list in a spare moment. I may not know the answer  
to your question, but if there was some judicious snipping of the  
original email I’d have a better shot at being able to answer. I’m sure  
I am not the only one.

Just a thought . . .

Best Wishes,  
Peter

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 19, 2011, 3:30pm UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/7 "2011-02-19T15:30:24Z")

</div>

Phil

On Sat, Feb 19, 2011 at 8:02 AM, Peter B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Feb 19, 2011, at 6:54 AM, deadnuker wrote:
> 
> > I cant seem to find the equivalent of those packages for mac. If someone  
> > knows the steps for MacOSX i would sureley apreciate it.

If you have XCode installed, that’s all you need as far as dev packages.  
It  
includes compilers, development libraries, and so forth. You don’t  
really  
need to worry about it, as long as XCode is more or less completely  
installed, you’re good. It may be worthwhile making sure you have the  
latest  
version (free download from Apple, after all), but otherwise, you’re  
good.

For latest versions of Mac OS X, XCode, and the mysql gem, I’ve had no  
troubles; but you used to need to do something like:

gem install mysql – with-mysql-config=/usr/local/mysql/bin/mysql\_config

The big caveat, of course, is checking to see that this path in the  
example  
above is actually correct. If your mysql is in /opt/local or somewhere  
else,  
look there instead. This used to be a very common hurdle for installing  
the  
mysql gem on Mac OS X, so a few good Google searches should get you more  
suggestions than you even want… 🙂

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 19, 2011, 5:24am UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/8 "2011-02-19T05:24:00Z")

</div>

In my case (CentOS 5.5) i id a

$sudo yum -y install mysql-devel

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 19, 2011, 3:46pm UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/9 "2011-02-19T15:46:39Z")

</div>

On Feb 19, 2011, at 9:43 AM, deadnuker wrote:

> See thats the thing I have done everything by the book. and with the feedback i  
> been getting but it stil says:
> 
> Building native extensions. This could take a while…  
> ERROR: Error installing mysql:  
> ERROR: Failed to build gem native extension.  
> Check the mkmf.log file for more  
> details. You may need configuration options.

Just to ask, what does it say in mkmf.log?

Best Wishes,  
Peter

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 19, 2011, 3:44pm UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/10 "2011-02-19T15:44:46Z")

</div>

See thats the thing I have done everything by the book. and with the  
feedback i been getting but it stil says:

Building native extensions. This could take a while…  
ERROR: Error installing mysql:  
_ERROR: Failed to build gem native extension._

```
    /usr/local/bin/ruby extconf.rb

```

–with-mysql-config=/usr/local/mysql/bin/mysql\_config  
checking for mysql\_ssl\_set()… \*\*\* 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.

Provided configuration options:  
–with-opt-dir  
–without-opt-dir  
–with-opt-include  
–without-opt-include=${opt-dir}/include  
–with-opt-lib  
–without-opt-lib=${opt-dir}/lib  
–with-make-prog  
–without-make-prog  
–srcdir=.  
–curdir  
–ruby=/usr/local/bin/ruby  
–with-mysql-config  
/usr/local/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': *The complier failed to generate an executable file. (RuntimeError)* *You have to install development tools first.* from /usr/local/lib/ruby/1.9.1/mkmf.rb:435:in`try\_link0’  
from /usr/local/lib/ruby/1.9.1/mkmf.rb:440:in `try_link' from /usr/local/lib/ruby/1.9.1/mkmf.rb:552:in`try\_func’  
from /usr/local/lib/ruby/1.9.1/mkmf.rb:797:in `block in have_func' from /usr/local/lib/ruby/1.9.1/mkmf.rb:693:in`block in checking\_for’  
from /usr/local/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone' from /usr/local/lib/ruby/1.9.1/mkmf.rb:254:in`open’  
from /usr/local/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone' from /usr/local/lib/ruby/1.9.1/mkmf.rb:254:in`open’  
from /usr/local/lib/ruby/1.9.1/mkmf.rb:276:in `postpone' from /usr/local/lib/ruby/1.9.1/mkmf.rb:692:in`checking\_for’  
from /usr/local/lib/ruby/1.9.1/mkmf.rb:796:in `have_func' from extconf.rb:50:in`’

Gem files will remain installed in  
/usr/local/lib/ruby/gems/1.9.1/gems/mysql-2.8.1 for inspection.

☹

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 19, 2011, 3:57pm UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/11 "2011-02-19T15:57:15Z")

</div>

this is what it says

"gcc -o conftest -I/usr/local/include/ruby-1.9.1/x86\_64-darwin10.6.0  
-I/usr/local/include/ruby-1.9.1/ruby/backward  
-I/usr/local/include/ruby-1.9.1 -I. -D\_XOPEN\_SOURCE -D\_DARWIN\_C\_SOURCE  
-I/usr/local/mysql/include -Os -g -fno-common -fno-strict-aliasing  
-arch  
i386 -D\_XOPEN\_SOURCE=1 -fno-common -pipe conftest.c -L.  
-L/usr/local/lib  
-L. -L/usr/local/mysql/lib -lmysqlclient -lpthread  
-lruby.1.9.1-static -lpthread -ldl -lobjc "  
In file included from /usr/local/include/ruby-1.9.1/ruby.h:32,  
from conftest.c:1:  
/usr/local/include/ruby-1.9.1/ruby/ruby.h:108: error: size of array  
ruby\_check\_sizeof\_long is negative  
/usr/local/include/ruby-1.9.1/ruby/ruby.h:112: error: size of array  
ruby\_check\_sizeof\_voidp is negative  
In file included from /usr/local/include/ruby-1.9.1/ruby/intern.h:29,  
from /usr/local/include/ruby-1.9.1/ruby/ruby.h:1327,  
from /usr/local/include/ruby-1.9.1/ruby.h:32,  
from conftest.c:1:  
/usr/local/include/ruby-1.9.1/ruby/st.h:69: error: size of array  
st\_check\_for\_sizeof\_st\_index\_t is negative  
checked program was:  
/\* begin _/  
1: #include “ruby.h”  
2:  
3: int main() {return 0;}  
/_ end \*/

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 19, 2011, 4:17pm UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/12 "2011-02-19T16:17:57Z")

</div>

Phil

On Sat, Feb 19, 2011 at 8:55 AM, deadnuker [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> from conftest.c:1:
> 
> ```
> 
> checked program was:  
> /\* begin _/  
> 1: #include “ruby.h”  
> 2:  
> 3: int main() {return 0;}  
> /_ end \*/

I see ruby 1.9.1 there. I would absolutely recommend 1.9.2 or 1.8.7  
instead… 1.9.1 had issues running rails, possibly other issues as  
well.

Not saying for certain that this is your problem with installing mysql,  
but  
you definitely want to change this; _don’t_ use ruby 1.9.1.

So you might as well get the latest 1.9.2 or 1.8.7 (since you’ll need  
one or  
the other anyways) and then try gem install mysql again.

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 19, 2011, 4:20pm UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/13 "2011-02-19T16:20:27Z")

</div>

the folder says 1.9.1 but im using v 1.9.2

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 19, 2011, 4:39pm UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/14 "2011-02-19T16:39:52Z")

</div>

Hi,

As Phil said, it’s good to change to 1.9.2.

I am also quiet sure (90%) that the problem is because of  
mysql-devel.xxx.  
I spent more than half day because of this problem.

If there is a way to check if mysql-devel or mysql-dev is installed, do  
that  
check to confirm the cause of the problem.

You have to get your mysql-devel from somewhere and install it.

Cheers,

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 19, 2011, 4:43pm UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/15 "2011-02-19T16:43:37Z")

</div>

i think you might be right but im not sure how to check for it. if  
someone  
knows that be a great help

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 19, 2011, 6:15pm UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/16 "2011-02-19T18:15:37Z")

</div>

i FINALLY figured out the problem and what a minute detail for the  
trouble  
it made.

i was using mysql 32bit version

when i changed to mysql64bit version the problem went away

I didnt think that would be such a horrible problem for a minor  
compability  
detail

Thanks for the feedback guys

---

<div class="post-metadata">

**Author:** ![webcraft](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@webcraft](https://www.ruby-forum.com/u/webcraft)\
**Post date:** [February 19, 2011, 6:21pm UTC](https://www.ruby-forum.com/t/mysql-gem-problems/203351/17 "2011-02-19T18:21:15Z")

</div>

Please check :

The key change for us Ruby developers, is the fact that, in Snow  
Leopard, all the interpreted languages (including Ruby) are now running  
in 64-bit by default (obviously, only if you have a 64-bit machine). For  
pure Ruby applications and libraries this shouldn’t pose any problems.  
But if you are migrating from a Leopard environment where you compiled C  
extensions for 32-bit only, these gems won’t properly load in Snow  
Leopard. Same thing goes for libraries you might have compiled in 32-bit  
mode and that you might want to use on your migrated system. via rails  
blog.

Enjoy!

Bruno Barros (@bkether)
