Ruby Gem Mysql Mac 10.6.8

时间:2014-01-24 15:54:13

标签: mysql ruby-on-rails ruby macos

我想为我在Github上分享的开源应用程序创建一个MySQL数据库:https://lobste.rs。它是一个Rails 4代码库,并为数据库使用SQL后端。我遵循了所有步骤,但是:

当我$ rake db:schema:load

答案是

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

我运行bundle install但是

$ 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

我相信我拥有Mac 10.6.8 Lion的Xcode版权。

有人知道我从终端安装mysql的ruby gem是多么有用吗?谢谢!

mkmf.log是:

"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 */

2 个答案:

答案 0 :(得分:0)

要回答有关从终端安装mysql gem的问题,请尝试运行:

gem install mysql2

答案 1 :(得分:0)

问题解决了。我确实必须重新安装适当的xCode版本,然后问题得到解决。不,我有mysql2正常运行。