source

mysql2 gem으로 앱을 설치하려고 하면 오류가 발생했습니다.

factcode 2022. 9. 17. 09:48
반응형

mysql2 gem으로 앱을 설치하려고 하면 오류가 발생했습니다.

오픈 소스 레일 3.2.21 어플리케이션을 설치하려고 합니다.mysql2보석은, 하지만 내가 그걸 실행하려고 할 때bundleCommant 다음 오류가 발생합니다.

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

의 모든 버전을 제거하려고 했습니다.mysql다음과 같이 홈브루를 사용하여 설치 및 재설치했습니다.

brew uninstall --force mysql && brew install mysql

실행 중:

sudo gem install mysql2

여기서도 같은 질문들이 많이 있습니다만, 위와 같은 에러가 발생합니다.

누가 이걸 어떻게 작동시키는지 안내 좀 해주시겠어요?

이 문제가 아직 발생하고 있는 유저의 경우:

brew를 통해 openssl을 설치하면 다음 메시지가 나타납니다.

Apple은 자체 TLS 및 암호화 라이브러리를 위해 OpenSSL 사용을 권장하지 않습니다.

일반적으로 당신에게는 이로 인한 결과는 없습니다.자체 소프트웨어를 빌드하고 이 수식이 필요한 경우 빌드 변수에 추가해야 합니다.

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

다음 작업을 수행하여 (로컬응용 프로그램에 대해) 이러한 빌드 플래그를 설정할 수 있습니다.

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

이건 나한테 효과가 있었어.

자세한 내용은 번들러 설명서를 참조하십시오.

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

ld: library not found for -lssl

이 때문에, 인스톨 할 필요가 있습니다.libssl:

brew install openssl

댓글로 지적된 바와 같이 라이브러리로 경로를 내보낼 필요가 있을 수 있습니다.

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

이것을 시험해 보세요.

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

(필요에 따라 버전 업데이트)

해결책은 Xcode 명령줄 도구를 설치하는 것이었습니다.

최근 Mac App Store를 통해 Xcode를 업데이트했는데 그때마다 Command Line Tools를 다시 설치해야 했습니다.

xcode-select --install

여기의 솔루션에 근거하고 있습니다.

brew install openssl

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

문제를 해결했다.

Homebrew 업데이트(openssl@1.1) 후 libs에 대한 새로운 경로가 있으므로 다음을 사용할 수 있습니다.

bundle config build.mysql2 --with-opt-dir=$(brew --prefix openssl)
bundle install

고쳐질 거야ld: library not found for -lssl error

@mudasobwa가 올바른 방향으로 안내해 주셔서 감사합니다.이 오류는 연결되지 않은 openssl 파일로 인해 발생하였으므로 다음을 수행합니다.

brew reinstall openssl && brew link openssl --force 

문제를 해결했다.여기서 솔루션을 찾았습니다.OpenSSL, RVM, Brew, conflicting error

맥북 에어 M1(macOS)에서는 작동했습니다.

zstd 설치

brew install zstd

mysql2 설치

gem install mysql2 -v '0.5.3' -- --with-opt-downsl=$(displays --opt openssl) --with-ldflags=-L/opt/homebrew/Cellar/zstd/1.5.0/lib

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

연락처 : https://gorails.com/setup/osx/10.14-mojave

명령의 조합으로 해결했습니다.모하비에 있어요

brew reinstall openssl && brew link openssl --force

그리고 나서.

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

Montrey M1 Mac에서의 스텝

brew install openssl@3

brew install zstd

gem install mysql2 -v '0.5.3' -- --with-opt-dir=$(brew --prefix openssl) --with-ldflags=-L/opt/homebrew/Cellar/zstd/1.5.0/lib

bundle config --local build.mysql2 "--with-opt-dir=$(brew --prefix openssl) --with-ldflags=-L/opt/homebrew/Cellar/zstd/1.5.0/lib"

bundle install

한 메인 것 .mysql2으로 장식하다

sudo apt-get install libsqlite3-dev libmysqlclient-dev -y

libsqlite3-dev합니다.

픽스를 : Homebrew 픽픽 catal catal catal catal catal Mac Catalina :gem install mysql2 -- --with-opt-dir="$(brew --prefix openssl)"

다음 명령어는 Mac os 12.1 MacOs Montrey에서 작동합니다.

 gem install mysql2 -v '0.5.3' -- \
 --with-mysql-lib=/opt/homebrew/Cellar/mysql/8.0.28/lib \
 --with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.28 \
 --with-mysql-config=/opt/homebrew/Cellar/mysql/8.0.28/bin/mysql_config \
 --with-mysql-include=/opt/homebrew/Cellar/mysql/8.0.28/include 

상세한 것에 대하여는, https://github.com/brianmario/mysql2/issues/1175 를 참조해 주세요.

MacOS Montrey 12.3(M1 Pro)에서 드디어 작동했습니다.

 gem install mysql2 -- --with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.28_1

인스톨 순서를 반드시 읽어 주세요.주목할 점은 다음과 같습니다.

  • 이인스톨 되어 있는 합니다(MySQL 의 인스톨).brew install mysql)
  • XCode 선택 도구가 설치되어 있는지 확인합니다(xcode-select --install)
  • 를 합니다.with-mysql-dir대한 ( with mysql)brew info mysql)

수 없이 는나 i i 、 는 、 는 、 는 、 i 、 i 、 i 、 i i i 。--with-opt-dir=/usr/local/opt.

가 '아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아~/.bundle/config 삭제:

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

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

반응형