ruby-on-rails - 无法为Rails项目安装mysql2 gem

标签 ruby-on-rails mysql2

我已经在Stackoverflow.com上查看并尝试了有关该主题的所有内容,但仍然无法弄清楚……

当我'gem install mysql2'时,出现权限错误。当我'sudo gem install mysql2'我得到以下信息:

    Teds-MacBook-Pro:~ tedmartin$ sudo gem install mysql2
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    current directory: /Users/tedmartin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5/ext/mysql2
/Users/tedmartin/.rbenv/versions/2.4.1/bin/ruby -r ./siteconf20170420-50202-1nekuvd.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
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
checking for rb_big_cmp()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for SSL_MODE_DISABLED in mysql.h... yes
checking for SSL_MODE_PREFERRED in mysql.h... yes
checking for SSL_MODE_REQUIRED in mysql.h... yes
checking for SSL_MODE_VERIFY_CA in mysql.h... yes
checking for SSL_MODE_VERIFY_IDENTITY in 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.9/lib
-----
creating Makefile

current directory: /Users/tedmartin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5/ext/mysql2
make "DESTDIR=" clean

current directory: /Users/tedmartin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5/ext/mysql2
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
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/tedmartin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5 for inspection.
Results logged to /Users/tedmartin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-15/2.4.0-static/mysql2-0.4.5/gem_make.out


任何有想法,建议,技巧,解决方法等的人……我将非常感谢。

谢谢!

最佳答案

this question的答案中,运行以下命令对我有用

gem install mysql2 --source 'https://rubygems.org/' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include

关于ruby-on-rails - 无法为Rails项目安装mysql2 gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43523389/

相关文章:

javascript - AngularJS 和 Rails 性能问题(更好地集成或分离) - js 和 css asset pipeline

ruby-on-rails - 在 Ruby (on Rails) 中使用 imgur API 获取图像

ruby-on-rails - 在脚本中使用不带 Rails 的 ActiveRecord 3.1

mysql - Ruby mysql2 单个查询中的多个语句

mysql - Ruby on Rails - 找不到 mysql2.so

ruby-on-rails - Rails.application.eager_load 是做什么的!做什么?

ruby-on-rails - 应该使用什么 postgres 运算符来比较数组/整数与数组?

ruby-on-rails - 启动 Rails 服务器时出现 ExecJS::RuntimeUnavailable 错误

mysql - 转换 MySQL 返回的编码错误的字符串

node.js - 即使传递数据具有不存在的字段/列,Sequelize 也会创建行