【问题标题】:MySQL Gem Install Error on Ruby 2.4Ruby 2.4 上的 MySQL Gem 安装错误
【发布时间】:2017-01-07 11:36:19
【问题描述】:

我在安装 mysql gem 时遇到问题。这是我的错误:

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

    current directory: /usr/local/rvm/gems/ruby-2.4.0/gems/mysql-2.9.1/ext/mysql_api
/usr/local/rvm/rubies/ruby-2.4.0/bin/ruby -r ./siteconf20170107-4120-x2dv85.rb extconf.rb
checking for mysql_ssl_set()... yes
checking for rb_str_set_len()... yes
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /usr/local/rvm/gems/ruby-2.4.0/extensions/x86_64-linux/2.4.0/mysql-2.9.1/mkmf.log

current directory: /usr/local/rvm/gems/ruby-2.4.0/gems/mysql-2.9.1/ext/mysql_api
make "DESTDIR=" clean

current directory: /usr/local/rvm/gems/ruby-2.4.0/gems/mysql-2.9.1/ext/mysql_api
make "DESTDIR="
compiling mysql.c
mysql.c: In function ‘stmt_bind_result’:
mysql.c:1320:74: error: ‘rb_cFixnum’ undeclared (first use in this function)
  else if (argv[i] == rb_cNumeric || argv[i] == rb_cInteger || argv[i] == rb_cFixnum)
                                                                          ^
mysql.c:1320:74: note: each undeclared identifier is reported only once for each function it appears in
mysql.c: At top level:
cc1: warning: unrecognized command line option "-Wno-self-assign"
cc1: warning: unrecognized command line option "-Wno-constant-logical-operand"
cc1: warning: unrecognized command line option "-Wno-parentheses-equality"
cc1: warning: unrecognized command line option "-Wno-tautological-compare"
Makefile:241: recipe for target 'mysql.o' failed
make: *** [mysql.o] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/local/rvm/gems/ruby-2.4.0/gems/mysql-2.9.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.4.0/extensions/x86_64-linux/2.4.0/mysql-2.9.1/gem_make.out

当我尝试这个命令 sudo gem install mysql -v '2.9.1' 时,它是有效的,我阅读了这一行来证明它的合理性......

sudo gem install mysql -v '2.9.1'
Building native extensions.  This could take a while...
Successfully installed mysql-2.9.1
Parsing documentation for mysql-2.9.1
Done installing documentation for mysql after 0 seconds
1 gem installed

我不明白发生了什么以及如何解决这个问题。如果有人可以帮助我...

【问题讨论】:

    标签: mysql ruby rubygems


    【解决方案1】:

    mysql gem 是许多不喜欢 Ruby 2.4 中的 unification of the integer types 的 gem 之一。

    不幸的是,由于 mysql gem 不再真正维护,我不会屏住呼吸等待更新版本。作为一种解决方法,您可以切换到 2.4 之前的 Ruby 版本,例如红宝石 2.3.3。

    或者,您可以切换到积极维护的mysql2 gem,它具有与 mysql gem 类似的 API,并且在其最新版本中与 Ruby 2.4 兼容。

    【讨论】:

    • 感谢您的回答,确实,Ruby 的版本是问题所在。我将检查更改为 mysql2 gem。
    • 从 mysql gem 更改为 mysql2 适用于 2.4.4p296。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-29
    • 2013-08-24
    • 2011-04-09
    • 2012-07-04
    • 1970-01-01
    相关资源
    最近更新 更多