安装MySQL(2.9.1)时出错,Bundler无法继续 [英] An error occurred while installing mysql (2.9.1), and Bundler cannot continue

查看:0
本文介绍了安装MySQL(2.9.1)时出错,Bundler无法继续的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此之前,我收到两个堆栈跟踪错误。它们是:

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': 

 The compiler failed to generate an executable file. (RuntimeError). 
 You have to install development tools first.

    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:546:in `block in try_link0'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tmpdir.rb:93:in `mktmpdir'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:543:in `try_link0'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:570:in `try_link'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:782:in `try_func'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1069:in `block in have_func'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in `postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1068:in `have_func'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20200218-95654-zjppya.rb extconf.rb
checking for mysql_ssl_set()... *** 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.

这是主要错误:或bundler告诉我的:

An error occurred while installing mysql (2.9.1), and Bundler cannot continue.
Make sure that `gem install mysql -v '2.9.1' --source 'http://rubygems.org/'` succeeds before bundling.

我做了大量的研究。

解决方案1(安装正确的开发人员工具):

安装Xcode和Xcode开发工具,运行命令:

xcode-select --install

我得到:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

我正在处理的项目需要Ruby版本1.9.3。

我真的不知道该做什么,因为我不知道头是什么,我已经通过bundler和重置Xcode输入了很多命令,以及删除工具和重新安装。当我使用捆绑包清理时--force我得到:

Could not find mysql-2.9.1 in any of the sources

我该怎么办?我已经查看了与此相关的其他内容,但命令不能修复它,我对MySQL 2.9.1也没有任何确切的了解。

编辑:我应该把这个贴进去,因为它要求我确保它正常工作:

mysql-2.9.1 git:(testupdategem) ✗ sudo gem install mysql -v '2.9.1'
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

        /Users/tblevins/.rvm/rubies/ruby-1.9.3-p545/bin/ruby extconf.rb
checking for mysql_ssl_set()... yes
checking for rb_str_set_len()... yes
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
creating Makefile

make
compiling mysql.c
mysql.c:79:2: error: unknown type name 'my_bool'
        my_bool *is_null;
        ^
mysql.c:361:5: error: use of undeclared identifier 'my_bool'
    my_bool b;
    ^
mysql.c:391:10: error: use of undeclared identifier 'MYSQL_SET_CLIENT_IP'; did you mean 'MYSQL_SET_CHARSET_DIR'?
    case MYSQL_SET_CLIENT_IP:
         ^~~~~~~~~~~~~~~~~~~
         MYSQL_SET_CHARSET_DIR
/usr/local/Cellar/mysql/8.0.19/include/mysql/mysql.h:176:3: note: 'MYSQL_SET_CHARSET_DIR' declared here
  MYSQL_SET_CHARSET_DIR,
  ^
mysql.c:398: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.19/include/mysql/mysql.h:187:3: note: 'MYSQL_DEFAULT_AUTH' declared here
  MYSQL_DEFAULT_AUTH,
  ^
mysql.c:400:6: error: use of undeclared identifier 'b'
            b = 1;
            ^
mysql.c:402:6: error: use of undeclared identifier 'b'
            b = 0;
            ^
mysql.c:403:14: error: use of undeclared identifier 'b'
        v = (char*)&b;
                    ^
mysql.c:391:10: error: duplicate case value 'MYSQL_SET_CHARSET_DIR'
    case MYSQL_SET_CLIENT_IP:
         ^
mysql.c:384:10: note: previous case defined here
    case MYSQL_SET_CHARSET_DIR:
         ^
mysql.c:588:9: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'unsigned int' [-Wshorten-64-to-32]
    n = mysql_num_rows(res);
      ~ ^~~~~~~~~~~~~~~~~~~
mysql.c:633:9: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'unsigned int' [-Wshorten-64-to-32]
    n = mysql_num_rows(res);
      ~ ^~~~~~~~~~~~~~~~~~~
mysql.c:878:5: error: use of undeclared identifier 'my_bool'
    my_bool true = 1;
    ^
mysql.c:883:61: error: cannot take the address of an rvalue of type 'int'
    if (mysql_stmt_attr_set(s, STMT_ATTR_UPDATE_MAX_LENGTH, &true))
                                                            ^~~~~
mysql.c:1068:73: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                int len = strlen(fields[i].table)+strlen(fields[i].name)+1;
                    ~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
mysql.c:1661:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    n = mysql_stmt_param_count(s->stmt);
      ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mysql.c:2049:52: error: use of undeclared identifier 'MYSQL_SECURE_AUTH'; did you mean 'MYSQL_DEFAULT_AUTH'?
    rb_define_const(cMysql, "SECURE_AUTH", INT2NUM(MYSQL_SECURE_AUTH));
                                                   ^~~~~~~~~~~~~~~~~
                                                   MYSQL_DEFAULT_AUTH
/Users/tblevins/.rvm/rubies/ruby-1.9.3-p545/include/ruby-1.9.1/ruby/ruby.h:973:35: note: expanded from macro 'INT2NUM'
# define INT2NUM(v) INT2FIX((int)(v))
                                  ^
/Users/tblevins/.rvm/rubies/ruby-1.9.3-p545/include/ruby-1.9.1/ruby/ruby.h:225:45: note: expanded from macro 'INT2FIX'
#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
                                            ^
/usr/local/Cellar/mysql/8.0.19/include/mysql/mysql.h:187:3: note: 'MYSQL_DEFAULT_AUTH' declared here
  MYSQL_DEFAULT_AUTH,
  ^
mysql.c:2050:61: error: use of undeclared identifier 'MYSQL_OPT_GUESS_CONNECTION'; did you mean 'MYSQL_OPT_RECONNECT'?
    rb_define_const(cMysql, "OPT_GUESS_CONNECTION", INT2NUM(MYSQL_OPT_GUESS_CONNECTION));
                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
                                                            MYSQL_OPT_RECONNECT
/Users/tblevins/.rvm/rubies/ruby-1.9.3-p545/include/ruby-1.9.1/ruby/ruby.h:973:35: note: expanded from macro 'INT2NUM'
# define INT2NUM(v) INT2FIX((int)(v))
                                  ^
/Users/tblevins/.rvm/rubies/ruby-1.9.3-p545/include/ruby-1.9.1/ruby/ruby.h:225:45: note: expanded from macro 'INT2FIX'
#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
                                            ^
/usr/local/Cellar/mysql/8.0.19/include/mysql/mysql.h:185:3: note: 'MYSQL_OPT_RECONNECT' declared here
  MYSQL_OPT_RECONNECT,
  ^
mysql.c:2051:68: error: use of undeclared identifier 'MYSQL_OPT_USE_EMBEDDED_CONNECTION'
    rb_define_const(cMysql, "OPT_USE_EMBEDDED_CONNECTION", INT2NUM(MYSQL_OPT_USE_EMBEDDED_CONNECTION));
                                                                   ^
mysql.c:2052:66: error: use of undeclared identifier 'MYSQL_OPT_USE_REMOTE_CONNECTION'
    rb_define_const(cMysql, "OPT_USE_REMOTE_CONNECTION", INT2NUM(MYSQL_OPT_USE_REMOTE_CONNECTION));
                                                                 ^
mysql.c:2053:54: error: use of undeclared identifier 'MYSQL_SET_CLIENT_IP'; did you mean 'MYSQL_SET_CHARSET_DIR'?
    rb_define_const(cMysql, "SET_CLIENT_IP", INT2NUM(MYSQL_SET_CLIENT_IP));
                                                     ^~~~~~~~~~~~~~~~~~~
                                                     MYSQL_SET_CHARSET_DIR
/Users/tblevins/.rvm/rubies/ruby-1.9.3-p545/include/ruby-1.9.1/ruby/ruby.h:973:35: note: expanded from macro 'INT2NUM'
# define INT2NUM(v) INT2FIX((int)(v))
                                  ^
/Users/tblevins/.rvm/rubies/ruby-1.9.3-p545/include/ruby-1.9.1/ruby/ruby.h:225:45: note: expanded from macro 'INT2FIX'
#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
                                            ^
/usr/local/Cellar/mysql/8.0.19/include/mysql/mysql.h:176:3: note: 'MYSQL_SET_CHARSET_DIR' declared here
  MYSQL_SET_CHARSET_DIR,
  ^
In file included from mysql.c:2287:
./error_const.h:2608:27: error: use of undeclared identifier 'ER_XPLUGIN_IP'
    rb_define_mysql_const(ER_XPLUGIN_IP);
                          ^
4 warnings and 16 errors generated.
make: *** [mysql.o] Error 1


Gem files will remain installed in /Users/tblevins/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/gems/1.9.1/gems/mysql-2.9.1 for inspection.
Results logged to /Users/tblevins/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/gems/1.9.1/gems/mysql-2.9.1/ext/mysql_api/gem_make.out

说明:使用curl -sSL https://get.rvm.io | bash -s stable安装RVM;重新启动您的外壳;使用RVM安装Ruby 1.9.3。

 Error running 'env GEM_HOME=/Users/tblevins/.rvm/gems/ruby-1.9.3- 
 p551@global GEM_PATH= /Users/tblevins/.rvm/rubies/ruby-1.9.3- 
 p551/bin/ruby -d /Users/tblevins/.rvm/src/rubygems-3.0.7/setup.rb -- 
 no-document', please read /Users/tblevins/.rvm/log/1582058102_ruby- 
 1.9.3-p551/rubygems.install.log 

表示这是rubyges.install.log文件:

 Exception LoadError' at /Users/tblevins/.rvm/rubies/ruby-1.9.3- 
 p551/lib/ruby/1.9.1/rubygems.rb:1264 - cannot load such file -- 
 rubygems/defaults/operating_system Exception LoadError' at /. 
 Users/tblevins/.rvm/rubies/ruby-1.9.3- 
 p551/lib/ruby/1.9.1/rubygems.rb:1273 - cannot load such file -- 
 rubygems/defaults/ruby. AND /Users/tblevins/.rvm/src/rubygems- 
 3.0.7/lib/rubygems/core_ext/kernel_warn.rb:18: void value expression 
 /Users/tblevins/.rvm/src/rubygems- 
 3.0.7/lib/rubygems/core_ext/kernel_warn.rb:43: syntax error, 
 unexpected '}', expecting keyword_end 

对于未来的观众:我必须做:

gem install mysql -- --with-cflags="-I/usr/local/opt/openssl/include" --with-ldflags="-L/usr/local/opt/openssl/lib"

我还必须清理我的BREW并链接git/node。这是一次又一次的尝试和失败,很抱歉我不记得所有的事情了。

我也这么做了:

bundle config --local build.mysql "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
捆绑包版本1.16.4 Ruby版本1.9.3-p551

推荐答案

欢迎使用堆栈溢出。

在回答您的问题之前,我推荐anothermh's advice。我一直在使用rbenv,因为我在一个团队中工作,其他人也这样做,但rvm很棒。不要使用Ruby的系统安装。如果您坚持使用Ruby开发,您会很高兴这样做的。

也就是说,设置非系统Ruby环境不足以解决此问题。首先,你看到的mysql宝石版是旧的,我想是2013年的。它依赖于不再受支持且具有多个安全漏洞的OpenSSL版本。请不要使用它。

如果可以,请切换到使用mysql2gem。对于大多数Ruby和Rails项目,mysql2gem非常接近于临时替代。如果最新版本的mysql2gem仍然无法在您的计算机上编译,请参阅this previous question以获取有关如何修复它的答案。

您可能处于一个令人难过的境地,mysql2gem升级不是您的选择。如果是这样的话,您需要找到OpenSSL库的1.0.x版本。在您的计算机上将旧版本的OpenSSL安装到某个路径--暂时将该路径命名为<openssl_path>。然后,您可以将该路径作为参数传递给bundler config,也可以直接安装gem,如下所示:

gem install mysql -v '2.9.1' -- --with-cflags="-I<openssl_path>/include" --with-ldflags="-L<openssl_path>/lib"

这仍然给您留下了查找OpenSSL1.0的问题。我知道之前有几个人发布了仍然通过自制软件安装它的方法,尽管有几个托管了运行所需下载的存储库不再活跃。也许在我上次查看之后,有人发了另一个帖子。我最近找不到一个。

在最坏的情况下,我想您可以转到https://www.openssl.org/source/old/下载一个旧版本并编译它。同样,我建议您升级到mysql2gem,因为这样对您来说可能更容易。

这篇关于安装MySQL(2.9.1)时出错,Bundler无法继续的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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