gem install mysql失败

Kyl*_*yle 11 ruby mysql macos rubygems ruby-on-rails

我按照http://geryit.com/blog/2011/01/installing-mysql-with-rails-on-mac-os-x-snow-leopard/上的说明进行操作,包括通过macport安装ruby.

每当我执行gem install mysql时 ,我都会收到以下错误

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

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


Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?我已经使用包文件(.pkg)安装了32位mysql,而且,我对ruby非常新...

更新4/26/11美国东部时间下午5:11 安装RVM并更新ruby到1.9.2此外,我查看了评论中发布的链接.我做了locate mysql_config ,结果是

/usr/local/mysql-5.1.56-osx10.6-x86/bin/mysql_config
/usr/local/mysql-5.1.56-osx10.6-x86/man/man1/mysql_config.1
Run Code Online (Sandbox Code Playgroud)

因此,我试过 gem install mysql - -with-mysql-config=/usr/local/mysql-5.1.56-osx10.6-x86/bin/mysql_config 但它仍然无法工作......但我确实得到了新的错误信息..

/Users/kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:435:in `try_link0'
    from /Users/kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:440:in `try_link'
    from /Users/kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:552:in `try_func'
    from /Users/kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:797:in `block in have_func'
    from /Users/kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
    from /Users/kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
    from /Users/kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
    from /Users/kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
    from /Users/kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
    from /Users/kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/mkmf.rb:796:in `have_func'
    from extconf.rb:50:in `<main>'


Gem files will remain installed in /Users/kyle/.rvm/rubies/ruby-1.9.2-p180/bin/th-mysql-config=/usr/local/mysql-5.1.56-osx10.6-x86/bin/mysql_config/gems/mysql-2.8.1 for inspection.
Run Code Online (Sandbox Code Playgroud)

非常希望感谢那些评论过的人......并且真的很感激如果能给予更多的帮助.....一直试图让安装了2天的darn mysql ...

Vic*_*cky 18

目前尚未安装程序'mysql_config'.您可以输入以下命令安装它:

$ sudo apt-get install libmysqlclient-dev
$ bundle install

bundle show [mysql2] # To find the location.
Run Code Online (Sandbox Code Playgroud)


Mik*_*mer 11

试试这个:

gem install mysql -- --with-mysql-config=/usr/local/mysql-5.1.56-osx10.6-x86/bin/mysql_config
Run Code Online (Sandbox Code Playgroud)

(注意额外的破折号)

如果这不起作用,我强烈建议使用MySQL上面提到的自制安装.你可以在这里阅读关于汤到坚果的安装:在Mac OS X 10.6上卸载Ruby on Rails

  • mac用户的提示:使用finder并"转到文件夹"找到你的mysql安装.找到配置文件后,将mysql_config图标从finder拖到终端,在终端窗口中显示路径 (3认同)
  • 对于自制软件0.9.4路径是`/ usr/local/Cellar/mysql/<version>/bin`,但它仍然不适合我...... (2认同)

tk1*_*404 9

我在Cent OS中遇到了同样的问题,但是通过安装mysql-devel解决了这个问题

 yum install mysql mysql-server mysql-devel
Run Code Online (Sandbox Code Playgroud)


Jam*_*hon 5

基于这个答案,我最终编辑了我/usr/local/Cellar/mysql/5.6.12/bin/mysql_config要删除的文件-Wno-null-conversion -Wno-unused-private-field,这就是mkmf.log抱怨的错误.

我的设置是Mac OSX,使用RVM安装Ruby,使用自制软件安装MySQL.


Kyl*_*yle 4

通过卸载我系统上的 32 位 MySQL 解决了问题..并安装了 5.1.56 64 位。

希望这对其他和我有同样问题的人有帮助。


归档时间:

查看次数:

33246 次

最近记录:

7 年,1 月 前