mysql2 Ruby Gem 无法安装 ubuntu 20.04

Rya*_*len 6 ruby rubygems ruby-on-rails bundler mysql2

有谁知道造成这种情况的原因以及如何解决它?我正在尝试为我的项目安装 ruby​​ gem,这是一个在 Rails 3 上运行的旧项目,但我在 ubuntu 20.04 上运行。我所做的基本上就是运行捆绑安装,然后我就可以让除了这个 ruby​​ gem 之外的所有东西都工作了。请指教!

\n
current directory: /home/decil/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/mysql2-0.3.21/ext/mysql2\nmake "DESTDIR=" clean\n\ncurrent directory: /home/decil/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/mysql2-0.3.21/ext/mysql2\nmake "DESTDIR="\ncompiling client.c\nclient.c: In function \xe2\x80\x98nogvl_read_query_result\xe2\x80\x99:\nclient.c:439:3: error: unknown type name \xe2\x80\x98my_bool\xe2\x80\x99; did you mean \xe2\x80\x98bool\xe2\x80\x99?\n  439 |   my_bool res = mysql_read_query_result(client);\n      |   ^~~~~~~\n      |   bool\nclient.c: In function \xe2\x80\x98rb_query\xe2\x80\x99:\nclient.c:687:14: warning: passing argument 1 of \xe2\x80\x98rb_rescue2\xe2\x80\x99 from incompatible pointer type [-Wincompatible-pointer-types]\n  687 |   rb_rescue2(do_send_query, (VALUE)&args, disconnect_and_raise, self, rb_eException, (VALUE)0);\n      |              ^~~~~~~~~~~~~\n      |              |\n      |              VALUE (*)(void *) {aka long unsigned int (*)(void *)}\nIn file included from /home/decil/.rbenv/versions/2.7.1/include/ruby-2.7.0/ruby.h:33,\n                 from ./mysql2_ext.h:8,\n                 from client.c:1:\n/home/decil/.rbenv/versions/2.7.1/include/ruby-2.7.0/ruby/ruby.h:1988:18: note: expected \xe2\x80\x98VALUE (*)(VALUE)\xe2\x80\x99 {aka \xe2\x80\x98long unsigned int (*)(long unsigned int)\xe2\x80\x99} but argument is of type \xe2\x80\x98VALUE (*)(void *)\xe2\x80\x99 {aka \xe2\x80\x98long unsigned int (*)(void *)\xe2\x80\x99}\n 1988 | VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...);\n      |                  ^~~~~~~~~~~~~~~\nclient.c:695:16: warning: passing argument 1 of \xe2\x80\x98rb_rescue2\xe2\x80\x99 from incompatible pointer type [-Wincompatible-pointer-types]\n  695 |     rb_rescue2(do_query, (VALUE)&async_args, disconnect_and_raise, self, rb_eException, (VALUE)0);\n      |                ^~~~~~~~\n      |                |\n      |                VALUE (*)(void *) {aka long unsigned int (*)(void *)}\nIn file included from /home/decil/.rbenv/versions/2.7.1/include/ruby-2.7.0/ruby.h:33,\n                 from ./mysql2_ext.h:8,\n                 from client.c:1:\n/home/decil/.rbenv/versions/2.7.1/include/ruby-2.7.0/ruby/ruby.h:1988:18: note: expected \xe2\x80\x98VALUE (*)(VALUE)\xe2\x80\x99 {aka \xe2\x80\x98long unsigned int (*)(long unsigned int)\xe2\x80\x99} but argument is of type \xe2\x80\x98VALUE (*)(void *)\xe2\x80\x99 {aka \xe2\x80\x98long unsigned int (*)(void *)\xe2\x80\x99}\n 1988 | VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...);\n      |                  ^~~~~~~~~~~~~~~\nclient.c: In function \xe2\x80\x98_mysql_client_options\xe2\x80\x99:\nclient.c:762:3: error: unknown type name \xe2\x80\x98my_bool\xe2\x80\x99; did you mean \xe2\x80\x98bool\xe2\x80\x99?\n  762 |   my_bool boolval;\n      |   ^~~~~~~\n      |   bool\nclient.c:797:10: error: \xe2\x80\x98MYSQL_SECURE_AUTH\xe2\x80\x99 undeclared (first use in this function); did you mean \xe2\x80\x98MYSQL_DEFAULT_AUTH\xe2\x80\x99?\n  797 |     case MYSQL_SECURE_AUTH:\n      |          ^~~~~~~~~~~~~~~~~\n      |          MYSQL_DEFAULT_AUTH\nclient.c:797:10: note: each undeclared identifier is reported only once for each function it appears in\nclient.c: In function \xe2\x80\x98set_secure_auth\xe2\x80\x99:\nclient.c:1185:38: error: \xe2\x80\x98MYSQL_SECURE_AUTH\xe2\x80\x99 undeclared (first use in this function); did you mean \xe2\x80\x98MYSQL_DEFAULT_AUTH\xe2\x80\x99?\n 1185 |   return _mysql_client_options(self, MYSQL_SECURE_AUTH, value);\n      |                                      ^~~~~~~~~~~~~~~~~\n      |                                      MYSQL_DEFAULT_AUTH\nclient.c:1186:1: warning: control reaches end of non-void function [-Wreturn-type]\n 1186 | }\n      | ^\nclient.c: At top level:\ncc1: warning: unrecognized command line option \xe2\x80\x98-Wno-self-assign\xe2\x80\x99\ncc1: warning: unrecognized command line option \xe2\x80\x98-Wno-parentheses-equality\xe2\x80\x99\ncc1: warning: unrecognized command line option \xe2\x80\x98-Wno-constant-logical-operand\xe2\x80\x99\nmake: *** [Makefile:245: client.o] Error 1\n
Run Code Online (Sandbox Code Playgroud)\n

Gom*_*thi 2

我在 0.4.5 版本中遇到了类似的问题,在 0.4.10 版本中它对我来说工作得很好

在您的 Gemfile 上尝试以下内容:

gem 'mysql2', '0.4.10'
Run Code Online (Sandbox Code Playgroud)