개발

맥] Rails Mysql2 gem 설치시 에러 해결하기

TK 2022. 1. 13. 14:17
반응형
> bin/bundle install
...
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
...
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
...
make: *** [mysql2.bundle] Error 1
make failed, exit code 2
...
An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'` succeeds before bundling.

이런식으로 설치가 안될때가 있다. 빌드시 라이브러리를 못찾아서 발생하는 문제이다.

> gem install mysql2 -v '0.5.2' -- --with-cflags=\"-I/usr/local/opt/openssl/include\" --with-ldflags=\"-L/usr/local/opt/openssl/lib\"

이렇게 하면 gem 설치가 가능하다.

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

bundler 를 이용해서 설치할때는 이런 식으로 하면 된다.

반응형