반응형
개인 프로젝트를 위해 프로젝트를 생성하고, mysql2
를 설치하기로 했습니다.
그런데 자꾸 에러가 뜨네요.
current directory:
/Users/hee/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/mysql2-0.5.3/ext/mysql2
make "DESTDIR="
compiling client.c
client.c:787:14: warning: incompatible pointer types passing 'VALUE (void *)'
(aka 'unsigned long (void *)') to parameter of type 'VALUE (*)(VALUE)' (aka
'unsigned long (*)(unsigned long)') [-Wincompatible-pointer-types]
rb_rescue2(do_send_query, (VALUE)&args, disconnect_and_raise, self,
rb_eException, (VALUE)0);
^~~~~~~~~~~~~
/Users/he/.rbenv/versions/2.7.0/include/ruby-2.7.0/ruby/ruby.h:1988:25:
note: passing argument to parameter here
VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...);
^
client.c:795:16: warning: incompatible pointer types passing 'VALUE (void *)'
(aka 'unsigned long (void *)') to parameter of type 'VALUE (*)(VALUE)' (aka
'unsigned long (*)(unsigned long)') [-Wincompatible-pointer-types]
rb_rescue2(do_query, (VALUE)&async_args, disconnect_and_raise, self,
rb_eException, (VALUE)0);
^~~~~~~~
/Users/hee/.rbenv/versions/2.7.0/include/ruby-2.7.0/ruby/ruby.h:1988:25:
note: passing argument to parameter here
VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...);
^
2 warnings generated.
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.bundle
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/hee/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/mysql2-0.5.3 for
inspection.
Results logged to
/Users/hee/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-19/2.7.0/mysql2-0.5.3/gem_make.out
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 before bundling.
몇 가지 해결방안을 찾아봤습니다.rbenv(ruby 2.7), MacOS Catalina 10.15.5, zsh
에서 진행했습니다.
MySQL
을 설치 및 실행
저는 Docker
로 돌릴 생각이었기 때문에, 로컬에 아직 mysql을 설치하지 않았었는데요,
그랬더니 젬 자체가 설치가 안 되네요. 로컬 환경에 mysql을 설치해 줍니다.
% brew install mysql
bundle
의 경로를 설정
mysql을 설치한 뒤로도 제대로 설치가 안 되어 찾아봤더니 Rails의 bundle
에 대해 경로를 설정할 필요가 있었습니다.
다음과 같이 진행합니다.
project_dir % export LDFLAGS="-L/usr/local/opt/openssl/lib"
project_dir % export CPPFLAGS="-I/usr/local/opt/openssl/include"
project_dir % bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib"
bundle config --local build.mysql2 "--with-cppflags=-I/usr/local/opt/openssl/include"
을 사용하라는 글도 있었는데요, 저는 이 설정으로는 설치 진행이 안 됐습니다.bundle config --local
명령어로 선언하면, .bundle
폴더 내 config
파일에 저장이 되네요.
이렇게 설정해주신 뒤 bundle install
을 하면 무사히 설치가 진행됩니다.
Bundle complete! 17 Gemfile dependencies, 74 gems now installed.
Gems in the group production were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
'개발 > Ruby on Rails' 카테고리의 다른 글
Rails에서 Vue에 데이터 전달하기 (1) | 2020.06.21 |
---|---|
Mac의 zsh에서 rbenv 사용하기 (0) | 2020.05.31 |
Ruby : 기초(6) 클래스 (0) | 2020.03.14 |
Ruby : 기초(5) 메소드 (0) | 2020.03.14 |
Ruby : 기초(4) 해시와 심볼 (0) | 2020.03.14 |