【发布时间】:2018-12-18 23:52:24
【问题描述】:
我正在使用 Mac High Sierra。我将 Ruby 2.2.1 与 RVM 一起使用。我需要在这个 Ruby on Rails 应用程序中使用 mysql2。我确实安装了mysql 5.7。我确实安装了 xcode 和命令行工具。
我只是想让这个公司应用程序在我的本地机器上运行。我知道我非常接近,但是当我进行捆绑安装时出现最后一个错误当我到达 mysql2 gem 时收到以下错误:
Fetching mysql2 0.3.18
Installing mysql2 0.3.18 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/ahayden/.rvm/gems/ruby-2.2.1/gems/mysql2-0.3.18/ext/mysql2
/Users/ahayden/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20180710-52515-2hjll8.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/local/Cellar/mysql-connector-c/6.1.11/lib
-----
creating Makefile
current directory: /Users/ahayden/.rvm/gems/ruby-2.2.1/gems/mysql2-0.3.18/ext/mysql2
make "DESTDIR=" clean
current directory: /Users/ahayden/.rvm/gems/ruby-2.2.1/gems/mysql2-0.3.18/ext/mysql2
make "DESTDIR="
compiling infile.c
compiling client.c
client.c:359:33: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
elapsed_time = end_time - start_time;
~ ~~~~~~~~~^~~~~~~~~~~~
client.c:1163:56: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32]
mysql2rb = mysql2_mysql_enc_name_to_rb(charset_name, charset_name_len);
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~
2 warnings generated.
compiling mysql2_ext.c
compiling result.c
result.c:186:17: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
for (i = 0; i < (len - 1); i++) {
~ ^ ~~~~~~~
1 warning generated.
linking shared-object mysql2/mysql2.bundle
ld: library not found for -l-lpthread
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/ahayden/.rvm/gems/ruby-2.2.1/gems/mysql2-0.3.18 for inspection.
Results logged to /Users/ahayden/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-17/2.2.0/mysql2-0.3.18/gem_make.out
An error occurred while installing mysql2 (0.3.18), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.18'` succeeds before bundling.
In Gemfile:
mysql2
我试过只安装没有特定 gem 版本的 mysql2 并且它可以工作,但它没有解决我的问题。它似乎归结为无法找到库-l-lpthread 的回溯的底部。请帮忙,我整天都在尝试这样做。
【问题讨论】:
-
你使用哪个命令安装mysql。 $brew 安装 mysql。如果您使用的是 rails 4,我建议您使用 mysql2 gem 和 0.4 系列。专门在你的 gemfile 中输入版本,然后做 bundle
-
不管怎样,我在通过 Homebrew 在 macOS (10.14.3) 上安装新版本的 MySQL (8.0.15) 时遇到了这个错误。无论如何,以下 Korayem 的解决方案对我有用。
标签: ruby-on-rails ruby rubygems mysql2