无法在Bigsur上安装mysql2 Gem [英] unable to install mysql2 Gem on Bigsur

查看:19
本文介绍了无法在Bigsur上安装mysql2 Gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Ruby 3.0.1p64 并使用MacOS Bigsur 11.04 MySQL已安装并正在运行

捆绑包安装要求我安装mysql2

我正在尝试安装mysql2 gem,如下所示:

sudo gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'

我收到了这个:

 Building native extensions. This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    current directory: /Users/henri/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/mysql2-0.5.3/ext/mysql2
/Users/henri/.rbenv/versions/3.0.1/bin/ruby -I /Users/henri/.rbenv/versions/3.0.1/lib/ruby/3.0.0 -r ./siteconf20210617-53969-y4phap.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdier
    --ruby=/Users/henri/.rbenv/versions/3.0.1/bin/$(RUBY_BASE_NAME)
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysql-config
    --without-mysql-config
    --with-mysqlclient-dir
    --without-mysqlclient-dir
    --with-mysqlclient-include
    --without-mysqlclient-include=${mysqlclient-dir}/include
    --with-mysqlclient-lib
    --without-mysqlclient-lib=${mysqlclient-dir}/lib
    --with-mysqlclientlib
    --without-mysqlclientlib
/Users/henri/.rbenv/versions/3.0.1/lib/ruby/3.0.0/mkmf.rb:1050:in `block in find_library': undefined method `split' for nil:NilClass (NoMethodError)
    from /Users/henri/.rbenv/versions/3.0.1/lib/ruby/3.0.0/mkmf.rb:1050:in `collect'
    from /Users/henri/.rbenv/versions/3.0.1/lib/ruby/3.0.0/mkmf.rb:1050:in `find_library'
    from extconf.rb:87:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/henri/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/extensions/arm64-darwin-20/3.0.0/mysql2-0.5.3/mkmf.log

extconf failed, exit code 1

我的mkmf.log如下所示:

    --------------------

have_func: checking for rb_wait_for_single_fd()... -------------------- yes

"clang -fdeclspec -o conftest -I/Users/henriknafo/.rbenv/versions/3.0.1/include/ru$
conftest.c:14:57: error: use of undeclared identifier 'rb_wait_for_single_fd'
int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_wait_for_single_fd; ret$
                                                        ^
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     int (* volatile tp)(void)=(int (*)(void))&t;
 9:     printf("%d", (*tp)());
10:   }
11:
12:   return !!argv[argc];
13: }
14: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_wait_for_single_fd;$
/* end */

这可能与Ruby 3.0.1不兼容吗? 我应该安装什么库才能安装mysql2gem get的安装

有没有人有建议?

推荐答案

我在捆绑包安装之前安装了mysql2,并在安装之前删除了名为.Bundle的文件夹:

gem install mysql2 -v '0.5.3' -- 
 --with-mysql-lib=/opt/homebrew/Cellar/mysql/8.0.25_1/lib 
 --with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.25_1 
 --with-mysql-config=/opt/homebrew/Cellar/mysql/8.0.25_1/bin/mysql_config 
 --with-mysql-include=/opt/homebrew/Cellar/mysql/8.0.25_1/include

现在我很好。

这篇关于无法在Bigsur上安装mysql2 Gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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