安装mysql(2.9.1)时出错,Bundler无法继续
An error occurred while installing mysql (2.9.1), and Bundler cannot continue
在此之前,我收到两个堆栈跟踪错误。它们是:
/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。
我真的不知道该怎么做,因为我不知道 headers 是什么,并且通过捆绑器输入了很多命令并重置 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\"
我还必须清理我的啤酒和 link 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
欢迎来到 Stack Overflow。
在我回答你的问题之前,我建议 。我一直在使用 rbenv,因为我在一个由其他人组成的团队中工作,但 rvm 很棒。不要使用Ruby的系统安装。如果您坚持 Ruby 开发,您会很高兴。
也就是说,设置非系统 ruby 环境不足以解决此问题。首先,您正在查看的 mysql
gem 版本是旧版本,我认为是从 2013 年开始的。它取决于不再受支持且具有多个安全漏洞的 openssl 版本。请不要使用它。
如果可以,切换到使用 mysql2
gem。对于大多数 Ruby 和 Rails 项目,mysql2
gem 非常接近于替代品。如果最新版本的 mysql2
gem 仍然无法在您的机器上编译,请参阅 this previous question 以获取有关如何修复它的答案。
您可能处于 mysql2
gem 升级不适合您的悲惨境地。如果是这种情况,您需要找到 1.0.x 版本的 OpenSSL 库。在您的计算机上将旧版本的 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\"
不过,这仍然会给您留下寻找 OpenSSL 1.0 的问题。我知道之前有几个人发布了仍然通过自制软件安装它的方法,尽管几个托管所需下载的存储库不再有效。自从我上次检查以来,也许有人发布了另一个。最近一直找不到。
在最坏的情况下,我想你可以去 https://www.openssl.org/source/old/ 下载一个旧版本并编译它。同样,我建议升级到 mysql2 gem,因为这对您来说可能更容易。
以下是 OSX 对我有用的内容:
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
gem install mysql -v '2.9.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。
我真的不知道该怎么做,因为我不知道 headers 是什么,并且通过捆绑器输入了很多命令并重置 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.
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\"
我还必须清理我的啤酒和 link 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
欢迎来到 Stack Overflow。
在我回答你的问题之前,我建议
也就是说,设置非系统 ruby 环境不足以解决此问题。首先,您正在查看的 mysql
gem 版本是旧版本,我认为是从 2013 年开始的。它取决于不再受支持且具有多个安全漏洞的 openssl 版本。请不要使用它。
如果可以,切换到使用 mysql2
gem。对于大多数 Ruby 和 Rails 项目,mysql2
gem 非常接近于替代品。如果最新版本的 mysql2
gem 仍然无法在您的机器上编译,请参阅 this previous question 以获取有关如何修复它的答案。
您可能处于 mysql2
gem 升级不适合您的悲惨境地。如果是这种情况,您需要找到 1.0.x 版本的 OpenSSL 库。在您的计算机上将旧版本的 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\"
不过,这仍然会给您留下寻找 OpenSSL 1.0 的问题。我知道之前有几个人发布了仍然通过自制软件安装它的方法,尽管几个托管所需下载的存储库不再有效。自从我上次检查以来,也许有人发布了另一个。最近一直找不到。
在最坏的情况下,我想你可以去 https://www.openssl.org/source/old/ 下载一个旧版本并编译它。同样,我建议升级到 mysql2 gem,因为这对您来说可能更容易。
以下是 OSX 对我有用的内容:
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
gem install mysql -v '2.9.1'
干杯!