programing tip

mysql2 gem으로 앱을 설치하려고 할 때 오류 발생

itbloger 2020. 11. 29. 10:00
반응형

mysql2 gem으로 앱을 설치하려고 할 때 오류 발생


mysql2gem 을 사용하는 오픈 소스 레일 3.2.21 애플리케이션을 설치하려고 하지만 명령을 실행하려고 bundle하면 다음 오류가 발생합니다.

Fetching: mysql2-0.3.18.gem (100%)
Building native extensions.  This could take a while...
p
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    /Users/my_username/.rvm/rubies/ruby-2.1.2/bin/ruby -r ./siteconf20150614-72129-orqsb7.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()... yes
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/5.6.25/lib
-----
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
linking shared-object mysql2/mysql2.bundle
ld: warning: directory not found for option '-L/Users/travis/.sm/pkg/active/lib'
ld: library not found for -lssl
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/my_username/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/mysql2-0.3.18 for inspection.
Results logged to /Users/my_username/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/extensions/x86

mysqlhomebrew를 통해 설치 한 모든 버전을 제거 하고 다음과 같이 다시 설치해 보았습니다 .

brew uninstall --force mysql && brew install mysql

그런 다음 실행 :

sudo gem install mysql2

여기에서 여러 가지 유사한 질문에서 제안한 것처럼 여전히 위와 동일한 오류가 발생합니다.

누군가 이것을 시작하고 실행하는 방법에 대한 지침을 제공 할 수 있습니까?


오류 로그에 다음과 같이 표시됩니다.

ld: library not found for -lssl

따라서 다음을 설치해야합니다 libssl.

brew install openssl

도움이 되었기를 바랍니다.


여전히 문제가 발생하는 경우 :

brew를 통해 openssl을 설치하면 다음 메시지가 표시됩니다.

Apple은 자체 TLS 및 암호화 라이브러리를 위해 OpenSSL 사용을 중단했습니다.

Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables:

LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig

You can set these build flags (for the local application) by running the following:

bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"

This worked for me.

See bundler's documentation for more information.


The solution for me was to install the Xcode Command Line Tools.

I had recently updated Xcode through the Mac App Store, and every time I do that, I've found that I have to reinstall the Command Line Tools again.

xcode-select --install

Try this:

gem install mysql2 -v '0.5.2' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include

(Update version as appropriate)


Based on the solution here

brew install openssl

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

solved the problem.


Thanks @mudasobwa for pointing me in the right direction. It turns out the error was caused by an unlinked openssl file, so running:

brew reinstall openssl && brew link openssl --force 

Solved the problem. I found the solution here: OpenSSL, RVM, Brew, conflicting error


sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

From here: https://gorails.com/setup/osx/10.14-mojave


I found that I had to use --with-opt-dir=/usr/local/opt.

Specifically, I added the following to my ~/.bundle/config file:

BUNDLE_BUILD__MYSQL2: "--with-opt-dir=/usr/local/opt"

참고URL : https://stackoverflow.com/questions/30834421/error-when-trying-to-install-app-with-mysql2-gem

반응형