Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I executed 'gem install mysql', the error message below appeared.

ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb
extconf.rb:10:in `require': no such file to load -- mkmf (LoadError)
    from extconf.rb:10

To workaround this, what should I do?

share|improve this question

From the error message, it seems that the ruby-dev package is missing. Try:

sudo apt-get install ruby1.8-dev

Hope it helps.

share|improve this answer
Thanks. But after the install, the error appeared.ERROR: Error installing mysql: ERROR: Failed to build gem native extension. *** 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. – Akira Tsuchiya Mar 7 '12 at 14:14
Looks like there are still some missing dependencies. Check that you have the build-essential package installed. After that, check that you have the following packages: mysql-server and libmysqlclient-dev. – Estanislau Trepat Mar 7 '12 at 14:38
Before, I would try to run gem uninstall mysql to remove the junk produced by previous installation attempts. It may fail, but that's ok as it's not actually installed anyway. – Estanislau Trepat Mar 7 '12 at 14:42
The build-essential, mysql-server, and libmysqlclient-dev are installed. But the same error occurs. – Akira Tsuchiya Mar 8 '12 at 0:04
  1. I added the 'ruby1.8-dev'.

    sudo apt-get install ruby1.8-dev

  2. Install mysql.

    sudo gem install mysql

  3. It seems to have worked fine. But annoying messages appear.

    No definition for next_result

    No definition for field_name

    No definition for field_table

    No definition for field_def


    Is this OK?

share|improve this answer

Glad that it finally worked.

Those error messages you're referring to I think they're generated by RDoc output (documentation). Those are just messages stating that there's no documentation available for certain function definitions. Shouldn't be much of a problem.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.