安装mysql(2.9.1)时发生错误,并且Bundler无法继续

问题描述 投票:0回答:1

在此之前,我在堆栈跟踪中遇到两个错误。这些是:

/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.

这是主要错误:还是捆绑程序告诉我的内容:

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。

我只是在做些事情上真的迷失了,因为我不知道标题是什么,并且已经通过捆绑程序输入了很多命令,并重置了xcode以及删除了工具并重新安装。当我使用bundle clean --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;重新启动您的shell;使用rvm install 1.9.3安装Ruby。

 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 

说这是rubygems.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\"

我还必须清理我的啤酒并链接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.4Ruby版本1.9.3-p551

ruby-on-rails ruby git macos bundler
1个回答
0
投票

欢迎使用堆栈溢出。

在回答您的问题之前,我会推荐anothermh's advice。我之所以使用rbenv是因为我与其他团队一起工作,但是rvm很棒。不要使用Ruby的系统安装。如果您坚持进行Ruby开发,那么您会很高兴的。

就是说,设置非系统红宝石环境不足以解决此问题。首先,我认为您要使用的mysql gem版本较旧,我认为是从2013年开始的。它取决于不再受支持且具有多个安全漏洞的openssl版本。请不要使用它。

[如果可以,请切换为使用mysql2宝石。对于大多数Ruby和Rails项目,mysql2 gem非常接近于直接替换。如果您的计算机上仍无法编译mysql2 gem的最新版本,请参见this previous question以获取有关如何修复它的答案。

[您可能处在悲伤的位置,无法升级mysql2宝石。如果是这种情况,则需要找到OpenSSL库的1.0.x版本。在计算机上将旧版本的OpenSSL安装到某个路径-现在暂时将该路径称为<openssl_path>。然后,您可以将该路径作为参数传递给捆包机,以代替$(brew prefix)命令,也可以像这样直接安装gem:

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

不过,这仍然使您面临寻找OpenSSL 1.0的问题。我知道以前有几个人发布了仍然可以通过自制程序安装该文件的方法,尽管托管该程序所需下载的几个存储库不再处于活动状态。自上次我检查后,也许有人发布了另一个。我最近找不到一个。

[最糟糕的是,我想您可以转到https://www.openssl.org/source/old/并下载旧版本并进行编译。再次,我建议升级到mysql2 gem,因为这对您来说可能是一条更容易的路径。

© www.soinside.com 2019 - 2024. All rights reserved.