0

I'm trying to learn Rails but I can't create a project using MySQL. I use MAMP for developing with PHP on OS X 10.9 so I'm trying to configure my Rails to run with it but I can't. If someone have some tutorial or clue what is happen here I'll be very thankful.

If I have to user apache and mysql without MAMP to resolve this its ok but just tell me if it is really necessary!

williamcalderipe@~/Projects/rails$ rails new mysql_app_test -d mysql

[...]

Fetching gem metadata from https://rubygems.org/...........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.8.4)
Using atomic (1.1.14)
Using thread_safe (0.1.3)
Using tzinfo (0.3.38)
Using activesupport (4.0.2)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.2)
Using mime-types (1.25.1)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.2)
Using activemodel (4.0.2)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.2)
Using activerecord (4.0.2)
Using bundler (1.5.3)
Using coffee-script-source (1.7.0)
Using execjs (2.0.2)
Using coffee-script (2.2.0)
Using thor (0.18.1)
Using railties (4.0.2)
Using coffee-rails (4.0.1)
Using hike (1.2.3)
Using jbuilder (1.5.3)
Using jquery-rails (3.1.0)
Using json (1.8.1)

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/williamcalderipe/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb 
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /Applications/MAMP/Library/bin/mysql_config
-----
checking for mysql.h... no
checking for mysql/mysql.h... yes
checking for errmsg.h... no
-----
errmsg.h is missing.  please check your installation of mysql and try again.
-----
*** 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=/Users/williamcalderipe/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/
    --with-mysql-config
    --without-mysql-config

extconf failed, exit code 1

Gem files will remain installed in /Users/williamcalderipe/.rvm/gems/ruby-2.0.0-p353/gems/mysql2-0.3.15 for inspection.
Results logged to /Users/williamcalderipe/.rvm/gems/ruby-2.0.0-p353/extensions/x86_64-darwin-12/2.0.0-static/mysql2-0.3.15/gem_make.out
An error occurred while installing mysql2 (0.3.15), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.15'` succeeds before bundling.

Heres my config/database.yml

development:
adapter: mysql2
encoding: utf8
database: mysql_app_test_development
pool: 5
username: root
password: root
host: localhost
socket: /Applications/MAMP/tmp/mysql/mysql.sock

And when I run rails s

Could not find gem 'mysql2 (>= 0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.

Ok.. So mysql2 is missing I did gem install mysql2

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

    /Users/williamcalderipe/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /Applications/MAMP/Library/bin/mysql_config
-----
checking for mysql.h... no
checking for mysql/mysql.h... yes
checking for errmsg.h... no
-----
errmsg.h is missing.  please check your installation of mysql and try again.
-----
*** 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:
[SAME CONFIGURATIONS AS THE FIRST CODE POSTED]

My XCode Version is 5.0.2 (5A3005) so when I exec xcode-select --instal and try install the Command lines tool this happen: enter image description here

Cald
  • 741
  • 2
  • 6
  • 15

1 Answers1

0

Here is the very helpful blog for installing / checking Mysql on OS X

http://blog.mclaughlinsoftware.com/2011/02/10/mac-os-x-mysql-install/

Sumit Munot
  • 3,748
  • 1
  • 32
  • 51