在 Ubuntu 20.04 上安装 mysql2 gem 版本“0.3.21”时出错
Error installing mysql2 gem version '0.3.21' on Ubuntu 20.04
我一直在尝试在我的 Ubuntu 20.04 上安装 mysql2 gem 版本 0.3.21
但出现以下错误。
构建本机扩展。这可能需要一段时间...
错误:安装 mysql2 时出错:
错误:无法构建 gem 本机扩展。
current directory: /home/user/.rvm/gems/ruby-2.5.3/gems/mysql2-0.3.21/ext/mysql2
/home/user/.rvm/rubies/ruby-2.5.3/bin/ruby -I /home/user/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0 -r ./siteconf20210822-101581-13t36qj.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /usr/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Setting libpath to /usr/lib/x86_64-linux-gnu
-----
creating Makefile
current directory: /home/user/.rvm/gems/ruby-2.5.3/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR=" clean
current directory: /home/user/.rvm/gems/ruby-2.5.3/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 ‘_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-constant-logical-operand’
cc1: warning: unrecognized command line option ‘-Wno-parentheses-equality’
make: *** [Makefile:242: client.o] Error 1
make failed, exit code 2
到目前为止,我在 Whosebug 上的其他类似问题中遵循了其他解决方案,例如安装 default-libmysqlclient-dev
libmysqlclient-dev
,但到目前为止没有运气。
我的 MySQL 服务器版本是 5.7.35
我解决了这个问题。我运行以下命令
gem install mysql2 -v '0.3.21' -- --srcdir=/var/lib/mysql
其中 srcdir 指向 mysql 的本地安装。
也许试试这个:
sudo apt remove libmysqlclient-dev
和
sudo apt install libmariadb-dev
我一直在尝试在我的 Ubuntu 20.04 上安装 mysql2 gem 版本 0.3.21
但出现以下错误。
构建本机扩展。这可能需要一段时间... 错误:安装 mysql2 时出错: 错误:无法构建 gem 本机扩展。
current directory: /home/user/.rvm/gems/ruby-2.5.3/gems/mysql2-0.3.21/ext/mysql2
/home/user/.rvm/rubies/ruby-2.5.3/bin/ruby -I /home/user/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0 -r ./siteconf20210822-101581-13t36qj.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /usr/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Setting libpath to /usr/lib/x86_64-linux-gnu
-----
creating Makefile
current directory: /home/user/.rvm/gems/ruby-2.5.3/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR=" clean
current directory: /home/user/.rvm/gems/ruby-2.5.3/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 ‘_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-constant-logical-operand’
cc1: warning: unrecognized command line option ‘-Wno-parentheses-equality’
make: *** [Makefile:242: client.o] Error 1
make failed, exit code 2
到目前为止,我在 Whosebug 上的其他类似问题中遵循了其他解决方案,例如安装 default-libmysqlclient-dev
libmysqlclient-dev
,但到目前为止没有运气。
我的 MySQL 服务器版本是 5.7.35
我解决了这个问题。我运行以下命令
gem install mysql2 -v '0.3.21' -- --srcdir=/var/lib/mysql
其中 srcdir 指向 mysql 的本地安装。
也许试试这个:
sudo apt remove libmysqlclient-dev
和
sudo apt install libmariadb-dev