mysql - 安装mysql2(0.3.21)时出错,Bundler无法继续
问题描述
当我尝试捆绑应用程序时弹出此错误的任何原因:我已尝试按照他们的建议安装 gem install mysql2 -v '0.3.21' 但无法正确安装。我也在 macOS High Sierra 上运行它。很抱歉我对这个问题的措辞不好,因为这是我第一次使用 ruby。
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/yamanshrestha/Desktop/Dorsata/vendor/bundle/ruby/2.3.0/extensions/universal-darwin-17/2.3.0/mysql2-0.3.21/mkmf.log
current directory: /Users/yamanshrestha/Desktop/Dorsata/vendor/bundle/ruby/2.3.0/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR=" clean
current directory: /Users/yamanshrestha/Desktop/Dorsata/vendor/bundle/ruby/2.3.0/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR="
compiling infile.c
compiling client.c
client.c:439:3: error: use of undeclared identifier 'my_bool'
my_bool res = mysql_read_query_result(client);
^
client.c:441: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.11/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:1185: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.11/include/mysql/mysql.h:188:3: note: 'MYSQL_DEFAULT_AUTH' declared here
MYSQL_DEFAULT_AUTH,
^
10 errors generated.
make: *** [client.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/yamanshrestha/Desktop/Dorsata/vendor/bundle/ruby/2.3.0/gems/mysql2-0.3.21 for inspection.
Results logged to /Users/yamanshrestha/Desktop/Dorsata/vendor/bundle/ruby/2.3.0/extensions/universal-darwin-17/2.3.0/mysql2-0.3.21/gem_make.out
An error occurred while installing mysql2 (0.3.21), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.21' --source 'http://rubygems.org/'` succeeds before bundling.
解决方案
通过降级我的mysql来修复。并使用 mysql v5.7 编译 mysql2。
对于 Mac 用户:
brew install mysql@5.7
gem install mysql2 -v '0.3.21' -- --with-mysql-include=/usr/local/Cellar/mysql@5.7/5.7.25/include/mysql --with-mysql-lib=/usr/local/Cellar/mysql@5.7/5.7.25/lib
参考:https ://github.com/brianmario/mysql2#configuration-options
推荐阅读
- python - 我有一个创建列表的循环,我需要运行该循环一定次数并获得所有列表总和的平均值
- angular - 如何在组件之间共享公共对象?
- java - 杰克逊没有正确反序列化 SetValuedMap
- android - 如何使用签名上传密钥创建 android app bundle (aab) 文件以进行发布?
- swift - 如何创建像附加图像一样的视图。上次看到的用户个人资料图片显示在此
- php - 如何使用特定键在多维数组中查找特定值
- java - Java 中有哪些 Exchanger 类的实时示例?
- codeigniter - Codeigniter 中的数据库插入
- objective-c - ipatool 因异常而失败:Xcode 10.1
- php - 每年每月或每周如何分离数据