네로개발일기

개발자 네로의 개발 일기, 자바를 좋아합니다 !

'web/Ruby on Rails'에 해당되는 글 6건


반응형

💻 OS: mac m1 os

❓Error: bundle install 또는 rails db:create 사용할 때 발생하는 에러

 

 

macOS (m1)에서 bundle install을 할 때 생기는 에러이다. (while bundle install for mysql2 gem ruby on mac)

둘 중에 한 에러가 뜰 수 있다. (나는 둘 다 번갈아서 에러가 발생했다.)

ld: library not found for -lzstd (zstd 라이브러리를 찾지 못함)

ld: library not found for -lssl (ssl 라이브러리를 찾지 못함)

$ bundle install
(생략)
Installing mysql2 0.5.3 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/Users/jyjeon/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mysql2-0.5.3/ext/mysql2
/Users/jyjeon/.rbenv/versions/2.6.5/bin/ruby -I
/Users/jyjeon/.rbenv/versions/2.6.5/lib/ruby/2.6.0 -r
./siteconf20210928-15542-ky3uai.rb extconf.rb
--with-ldflags\=-L/opt/homebrew/Cellar/zstd/1.5.0/lib
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
-----
Using mysql_config at /opt/homebrew/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.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 MYSQL.net.vio in mysql.h... yes
checking for MYSQL.net.pvio in mysql.h... no
checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in mysql.h... yes
checking for SERVER_QUERY_NO_GOOD_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_NO_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_WAS_SLOW in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_ON in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_OFF in mysql.h... yes
checking for my_bool in mysql.h... no

-----
Don't know how to set rpath on your system, if MySQL libraries are not in path
mysql2 may not load
-----
-----
Setting libpath to /opt/homebrew/Cellar/mysql/8.0.26/lib
-----
(생략)
make "DESTDIR=" clean
(생략)
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
(생략)
An error occurred while installing mysql2 (0.5.3), and Bundler cannot

continue.

In Gemfile:
  mysql2

 

$ rails db:create
linking shared-object mysql2/mysql2.bundle
ld: library not found for -lzstd
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

이런 에러가 발생한다.

해결책은 bundle clean을 해주면 안 되는 경우가 있다. 그럴 경우 --force를 통해 해 준다.

bundle clean --force
brew uninstall mysql
brew install mysql

mysql이 깔려있을 경우 brew를 사용해서 삭제 후 재설치

 

1) ld: library not found for -lssl (ssl 라이브러리를 찾지 못함)

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

2) ld: library not found for -lzstd (zstd 라이브러리를 찾지 못함)

bundle config --local build.mysql2 "--with-ldflags=-L/opt/homebrew/Cellar/zstd/1.5.0/lib"

두 명령어 중 하나를 실행해주면 된다.

되지 않을 때는  sudo명령어를 사용해서 실행함.

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

 

라이브러리 위치를 찾지 못해서 생기는 문제 같다.

 

출처

https://stackoverflow.com/questions/67840691/ld-library-not-found-for-lzstd-while-bundle-install-for-mysql2-gem-ruby-on-mac

 

ld: library not found for -lzstd while bundle install for mysql2 gem Ruby on macOS Big Sur 11.4

while running bundle install An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'` succeeds

stackoverflow.com

 

728x90
반응형
blog image

Written by ner.o

개발자 네로의 개발 일기, 자바를 좋아합니다 !