安装 mysql2 时出错:错误:无法构建 gem 本机扩展 [英] Error installing mysql2: ERROR: Failed to build gem native extension

查看:196
本文介绍了安装 mysql2 时出错:错误:无法构建 gem 本机扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用(Mac Os)

I'm using (Mac Os)

gem 'rails', '~> 4.2.0'             # rails edge
ruby '2.2.0'
gem 'mysql2'

运行 bundle 后出现此错误

After running bundle i got this error

安装mysql2(0.3.17)时出错,Bundler不能继续.确保 gem install mysql2 -v '0.3.17' 成功捆绑前.

An error occurred while installing mysql2 (0.3.17), and Bundler cannot continue. Make sure that gem install mysql2 -v '0.3.17' succeeds before bundling.

所以我建议我跑

gem install mysql2 -v '0.3.17'

而且我不断收到此错误,尽管我尝试了很多解决方案,但不幸的是没有运气

And i'm getting this error continuously, though i tried many solutions, unfortunately no luck

> adware:page365 apple$ gem install mysql2 -v '0.3.17 ' Error loading
> RubyGems plugin
> "/Users/apple/.rvm/gems/ruby-2.2.0/gems/yard-0.8.7.6/lib/rubygems_plugin.rb":
> can't modify frozen Hash (RuntimeError) Building native extensions.
> This could take a while... ERROR:  Error installing mysql2:   ERROR:
> Failed to build gem native extension.
> 
>     current directory: /Users/apple/.rvm/gems/ruby-2.2.0/gems/mysql2-0.3.17/ext/mysql2
> /Users/apple/.rvm/rubies/ruby-2.2.0/bin/ruby -r
> ./siteconf20181030-12196-9cfizd.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/local/bin/mysql_config
> ----- checking for mysql.h... yes checking for errmsg.h... yes checking for mysqld_error.h... yes
> ----- Setting rpath to /usr/local/Cellar/mysql/8.0.12/lib
> ----- creating Makefile
> 
> current directory:
> /Users/apple/.rvm/gems/ruby-2.2.0/gems/mysql2-0.3.17/ext/mysql2 make
> "DESTDIR=" clean
> 
> current directory:
> /Users/apple/.rvm/gems/ruby-2.2.0/gems/mysql2-0.3.17/ext/mysql2 make
> "DESTDIR=" compiling infile.c compiling client.c client.c:359:33:
> warning: implicit conversion loses integer precision: 'long' to
> 'unsigned int' [-Wshorten-64-to-32]
>         elapsed_time = end_time - start_time;
>                      ~ ~~~~~~~~~^~~~~~~~~~~~ client.c:431:3: error: use of undeclared identifier 'my_bool'   my_bool res =
> mysql_read_query_result(client);   ^ client.c:433:19: error: use of
> undeclared identifier 'res'   return (void *)(res == 0 ? Qtrue :
> Qfalse);
>                   ^ client.c:762:3: error: use of undeclared identifier 'my_bool'   my_bool boolval;   ^ client.c:793:7: error: use
> of undeclared identifier 'boolval'
>       boolval = (value == Qfalse ? 0 : 1);
>       ^ client.c:794:17: error: use of undeclared identifier 'boolval'
>       retval = &boolval;
>                 ^ client.c:797:10: error: use of undeclared identifier 'MYSQL_SECURE_AUTH'; did you mean 'MYSQL_DEFAULT_AUTH'?
>     case MYSQL_SECURE_AUTH:
>          ^~~~~~~~~~~~~~~~~
>          MYSQL_DEFAULT_AUTH /usr/local/Cellar/mysql/8.0.12/include/mysql/mysql.h:188:3: note:
> 'MYSQL_DEFAULT_AUTH' declared here   MYSQL_DEFAULT_AUTH,   ^
> client.c:798:7: error: use of undeclared identifier 'boolval'
>       boolval = (value == Qfalse ? 0 : 1);
>       ^ client.c:799:17: error: use of undeclared identifier 'boolval'
>       retval = &boolval;
>                 ^ client.c:830:38: error: use of undeclared identifier 'boolval'
>         wrapper->reconnect_enabled = boolval;
>                                      ^ client.c:1163:56: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned
> long') to 'unsigned int' [-Wshorten-64-to-32]   mysql2rb =
> mysql2_mysql_enc_name_to_rb(charset_name, charset_name_len);
>              ~~~~~~~~~~~~~~~~~~~~~~~~~~~               ^~~~~~~~~~~~~~~~ client.c:1196:38: error: use of undeclared identifier
> 'MYSQL_SECURE_AUTH'; did you mean 'MYSQL_DEFAULT_AUTH'?   return
> _mysql_client_options(self, MYSQL_SECURE_AUTH, value);
>                                      ^~~~~~~~~~~~~~~~~
>                                      MYSQL_DEFAULT_AUTH /usr/local/Cellar/mysql/8.0.12/include/mysql/mysql.h:188:3: note:
> 'MYSQL_DEFAULT_AUTH' declared here   MYSQL_DEFAULT_AUTH,   ^ 2
> warnings and 10 errors generated. make: *** [client.o] Error 1
> 
> make failed, exit code 2
> 
> Gem files will remain installed in
> /Users/apple/.rvm/gems/ruby-2.2.0/gems/mysql2-0.3.17 for inspection.
> Results logged to
> /Users/apple/.rvm/gems/ruby-2.2.0/extensions/x86_64-darwin-18/2.2.0/mysql2-0.3.17/gem_make.out

任何帮助将不胜感激!

推荐答案

安装mysql2依赖后安装gem

brew install mysql-client libmysqlclient-dev

这篇关于安装 mysql2 时出错:错误:无法构建 gem 本机扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆