ruby-on-rails - mysql2 Ruby Gem 无法安装 ubuntu 20.04

标签 ruby-on-rails ruby rubygems bundler mysql2

有谁知道这是什么原因造成的,我该如何解决?我正在尝试为我的项目安装一个 ruby​​ gem,这是一个在 rails 3 上运行的旧项目,但我在 ubuntu 20.04 上运行。我所做的基本上就是运行 bundle install ,然后我让除了这个 ruby​​ gem 之外的所有其他东西都能正常工作。请指教!

current directory: /home/decil/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR=" clean

current directory: /home/decil/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR="
compiling client.c
client.c: In function ‘nogvl_read_query_result’:
client.c:439:3: error: unknown type name ‘my_bool’; did you mean ‘bool’?
  439 |   my_bool res = mysql_read_query_result(client);
      |   ^~~~~~~
      |   bool
client.c: In function ‘rb_query’:
client.c:687:14: warning: passing argument 1 of ‘rb_rescue2’ from incompatible pointer type [-Wincompatible-pointer-types]
  687 |   rb_rescue2(do_send_query, (VALUE)&args, disconnect_and_raise, self, rb_eException, (VALUE)0);
      |              ^~~~~~~~~~~~~
      |              |
      |              VALUE (*)(void *) {aka long unsigned int (*)(void *)}
In file included from /home/decil/.rbenv/versions/2.7.1/include/ruby-2.7.0/ruby.h:33,
                 from ./mysql2_ext.h:8,
                 from client.c:1:
/home/decil/.rbenv/versions/2.7.1/include/ruby-2.7.0/ruby/ruby.h:1988:18: note: expected ‘VALUE (*)(VALUE)’ {aka ‘long unsigned int (*)(long unsigned int)’} but argument is of type ‘VALUE (*)(void *)’ {aka ‘long unsigned int (*)(void *)’}
 1988 | VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...);
      |                  ^~~~~~~~~~~~~~~
client.c:695:16: warning: passing argument 1 of ‘rb_rescue2’ from incompatible pointer type [-Wincompatible-pointer-types]
  695 |     rb_rescue2(do_query, (VALUE)&async_args, disconnect_and_raise, self, rb_eException, (VALUE)0);
      |                ^~~~~~~~
      |                |
      |                VALUE (*)(void *) {aka long unsigned int (*)(void *)}
In file included from /home/decil/.rbenv/versions/2.7.1/include/ruby-2.7.0/ruby.h:33,
                 from ./mysql2_ext.h:8,
                 from client.c:1:
/home/decil/.rbenv/versions/2.7.1/include/ruby-2.7.0/ruby/ruby.h:1988:18: note: expected ‘VALUE (*)(VALUE)’ {aka ‘long unsigned int (*)(long unsigned int)’} but argument is of type ‘VALUE (*)(void *)’ {aka ‘long unsigned int (*)(void *)’}
 1988 | VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...);
      |                  ^~~~~~~~~~~~~~~
client.c: In function ‘_mysql_client_options’:
client.c:762:3: error: unknown type name ‘my_bool’; did you mean ‘bool’?
  762 |   my_bool boolval;
      |   ^~~~~~~
      |   bool
client.c:797:10: error: ‘MYSQL_SECURE_AUTH’ undeclared (first use in this function); did you mean ‘MYSQL_DEFAULT_AUTH’?
  797 |     case MYSQL_SECURE_AUTH:
      |          ^~~~~~~~~~~~~~~~~
      |          MYSQL_DEFAULT_AUTH
client.c:797:10: note: each undeclared identifier is reported only once for each function it appears in
client.c: In function ‘set_secure_auth’:
client.c:1185:38: error: ‘MYSQL_SECURE_AUTH’ undeclared (first use in this function); did you mean ‘MYSQL_DEFAULT_AUTH’?
 1185 |   return _mysql_client_options(self, MYSQL_SECURE_AUTH, value);
      |                                      ^~~~~~~~~~~~~~~~~
      |                                      MYSQL_DEFAULT_AUTH
client.c:1186:1: warning: control reaches end of non-void function [-Wreturn-type]
 1186 | }
      | ^
client.c: At top level:
cc1: warning: unrecognized command line option ‘-Wno-self-assign’
cc1: warning: unrecognized command line option ‘-Wno-parentheses-equality’
cc1: warning: unrecognized command line option ‘-Wno-constant-logical-operand’
make: *** [Makefile:245: client.o] Error 1

最佳答案

我在 0.4.5 版上遇到了类似的问题,0.4.10 版对我来说效果很好
尝试在您的 Gemfile 上使用以下内容:

gem 'mysql2', '0.4.10'

关于ruby-on-rails - mysql2 Ruby Gem 无法安装 ubuntu 20.04,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63491235/

相关文章:

mysql - 运行 Rails 迁移后如何对这个 MySQL 重复条目错误进行分类?

ruby - Ruby 中优雅的日期解析

ruby - 使用 Ruby 创建 Git 提交并推送到 GitHub

ruby-on-rails - rake rails :freeze:gems and rake gems:unpack? 之间有什么区别

ruby-on-rails - 为什么将 redis 添加到 Gemfile 会修复错误 : require 'redis'

ruby-on-rails - Ruby on Rails的托管

ruby-on-rails - 获取 Hash 对象的循环次数

ruby - Rails 应用程序中类(class)的位置

ruby-on-rails - Rails 错误:执行时(Gem::RemoteFetcher::UnknownHostError)

javascript - 在 ruby​​ on rails 的文本字段中动态显示数据