无法安装旧的mysql2 gem [英] Failure to install old mysql2 gem

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

问题描述

我正在使用Mac High Sierra.我在RVM上使用Ruby 2.2.1.我需要在此Ruby on Rails应用程序中使用mysql2.我确实安装了mysql 5.7.我确实已经安装了xcode和命令行工具.

I am using Mac High Sierra. I am using Ruby 2.2.1 with RVM. I need to use mysql2 with this Ruby on Rails app. I do have mysql 5.7 installed. I do have xcode installed along with the command-line tools.

我只是想让该公司应用程序在我的本地计算机上运行.我知道我已经很接近了,但是当我进行捆绑安装时遇到一个最后的错误,当我进入mysql2 gem时会收到以下错误:

I am simply trying to get this company app working on my local machine. I know that I am very close but I have one final error when I do bundle install I receive the following error when I get to the 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的追溯的底部.请帮忙,我整天都在尝试这样做.

I've tried just installing mysql2 without the specific gem version and it works, but it did not fix my problem. It seems to boil down to the bottom of the traceback where it cannot find library -l-lpthread. Please help, I've been trying to do this all day.

推荐答案

根据共享的说明,似乎mysql依赖项无法安装.

As per the description shared it seems like the mysql dependencies are unable to install.

首先,我们需要定位mysql_config",然后将以下命令中的路径替换为该文件的位置.

First we need to ‘locate mysql_config’ and then replace the path in the following command with where that file is.

gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

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

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