0

I would like to create a MySQL database for an open source app I've forked on Github: https://lobste.rs. It is a Rails 4 codebase and uses a SQL backend for the database. I've follow all the steps but:

When I $ rake db:schema:load

The answer is

Could not find mysql2-0.3.14 in any of the sources
Run `bundle install` to install missing gems.

I run bundle install but

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

    /User/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... *** 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
    --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=/User/.rvm/rubies/ruby-1.9.3-p429/bin/ruby
    --with-mysql-config
    --without-mysql-config
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysqlclientlib
    --without-mysqlclientlib
/User/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /User/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
    from /User/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
    from /User/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
    from /User/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:870:in `block in find_library'
    from /User/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from /User/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from /User/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /User/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from /User/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /User/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from /User/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from /User/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:866:in `find_library'
    from extconf.rb:39:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /User/.rvm/gems/ruby-1.9.3-p429/gems/mysql-2.9.1 for inspection.
Results logged to /User/.rvm/gems/ruby-1.9.3-p429/extensions/x86_64-darwin-10/1.9.1/mysql-2.9.1/gem_make.out

I believe I have the rights Xcode version for my Mac 10.6.8 Lion.

Does anybody know how cain I install the ruby gem of mysql from the terminal? Thanks!

The mkmf.log is:

"gcc-4.2 -o conftest -I/User/.rvm/rubies/ruby-1.9.3-p429/include/ruby-1.9.1/x86_64-darwin10.8.0 -I/User/.rvm/rubies/ruby-1.9.3-p429/include/ruby-1.9.1/ruby/backward -I/User/.rvm/rubies/ruby-1.9.3-p429/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include  -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration  -fno-common -pipe conftest.c  -L. -L/Users/miguelcarvajal/.rvm/rubies/ruby-1.9.3-p429/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib      -lruby.1.9.1  -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */
mcarvajal
  • 63
  • 1
  • 8

2 Answers2

0

To answer your question about installing the mysql gem from your terminal, try running:

gem install mysql2
NM Pennypacker
  • 6,704
  • 11
  • 36
  • 38
  • It happens exactly the same: `Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /User/.rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb checking for ruby/thread.h... *** 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.` – mcarvajal Jan 24 '14 at 17:12
  • Have you enabled the command line tools in Xcode? Check out this post: http://stackoverflow.com/questions/13279856/the-compiler-failed-to-generate-an-executable-file-runtimeerror – NM Pennypacker Jan 24 '14 at 17:15
0

Problem solved. I did have to re-install the appropriate xCode version and then the problem was fixed. No I have mysql2 up and running correctly.

mcarvajal
  • 63
  • 1
  • 8