1

I'm trying to set up rails for the first time. I've got the app made, I've been following lots of guides.

When I try to install the mysql gem gem install mysql

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

        /usr/bin/ruby extconf.rb
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... no
checking for mysql/mysql.h... 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.

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/bin/ruby
        --with-mysql-config
        --without-mysql-config

Looking around on SO and Google, people say to do:

gem install mysql --with-mysql-config=/usr/bin/mysql_config

but I get:

ERROR:  While executing gem ... (OptionParser::InvalidOption)
    invalid option: --with-mysql-config=/usr/bin/mysql_config

Any ideas on how I can get this to work?

2
  • 2
    what platform are you on? Mac? Linux? Commented Feb 13, 2012 at 21:52
  • 1
    What distribution? Ubuntu? Debian? Commented Feb 13, 2012 at 22:05

1 Answer 1

1

If you haven't already you'll need to install the MySQL development library as root:

yum install mysql-devel

Then in the gem install command you need to have another -- in the command line before the --with-mysql-config option:

gem install mysql -- --with-mysql-config=/usr/bin/mysql_config
Sign up to request clarification or add additional context in comments.

4 Comments

when I use yum I get: There was a problem importing one of the Python modules required to run yum. The error leading to this problem was: /usr/lib64/python2.4/lib-dynload/datetime.so: failed to map segment from shared object: Cannot allocate memory
Yikes. I Googled that error message and others are getting that same error. It usually indicates an actual memory issue. This post has a good possible solution: centos.org/modules/newbb/viewtopic.php?topic_id=20849 Run ulimit -m unlimited -d unlimited -v unlimited to allow unlimited memory. I'd be careful with setting that though... you might want to check if something else is eating up your memory.
I'm going to wait before I try that to hear back from the host. They might have more info on what's running. It is a shared host, so it's possible some other user is using large amounts of memory.
I'm getting mysql.h is missing even with --with-mysql-lib, and there is no /Applications/XAMPP/xamppfiles/include/ directory although mysql is working when using xampp.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.