无法为铁路项目安装MySQL2 GEM



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

当我'gem安装mysql2'时,我会遇到权限错误。当我'sudo gem安装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

任何有想法,建议,小费,修复等的人...我真的很感激。

谢谢!

在这个问题上的答案中,运行以下操作对我有用

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

我在莫哈韦(Mojave(上遇到了同样的问题,以前的答案对我没有任何作用,但是此github问题中提到的命令dimp

步骤1。

brew install openssl

步骤2。

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

就我而言,我已经安装了openssl,所以实际上是解决问题的导出命令。

  1. 确保OpenSSL通过Homebrew安装在Mac上。
brew install openssl
  1. 安装mysql2宝石。
gem install mysql2 -v '0.5.2' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
  1. 如果未解决该错误,则以上解决方案是最后一个
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

如果上述解决方案不起作用。

cd /usr/local/Cellar/openssl/1.0.2s/lib/
sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/local/lib

这在Macos Catalina上对我有用:

确保已安装了OpenSSL。如果不是:

brew install openssl

然后进行宝石安装:

gem install mysql2 -- --with-opt-dir="$(brew --prefix openssl)"

尝试以下:

which mysql

然后,使用现有的MySQL安装目录使用输出结果来安装GEM:

gem install mysql2 -- --with-mysql-dir=<mysql-installation-directory>

它在2h疯狂

之后为我工作
  1. 卸载Ruby并安装Ruby v2.6.6
  2. 运行命令行作为管理员gem install mysql2
  3. 安装导轨gem install rails
  4. 创建新项目rails new my_proj -d mysql

在Windown中100%工作

最新更新