๊ด€๋ฆฌ ๋ฉ”๋‰ด

๋„ค๋กœ๊ฐœ๋ฐœ์ผ๊ธฐ

[Ruby on Rails] bundle install mysql2 error on Mac m1 (zstd ssl library not found) ๋ณธ๋ฌธ

web/Ruby on Rails

[Ruby on Rails] bundle install mysql2 error on Mac m1 (zstd ssl library not found)

ner.o 2021. 9. 28. 11:46
728x90
๋ฐ˜์‘ํ˜•

๐Ÿ’ป 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
๋ฐ˜์‘ํ˜•
1 Comments
๋Œ“๊ธ€์“ฐ๊ธฐ ํผ