Mac에서 gems를 활용해 mysql2 라이브러리를 설치할 수 없는 경우

2013-05-02 10:50
javajigi:humhum javajigi$ gem install mysql2
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
	ERROR: Failed to build gem native extension.


        /Users/javajigi/.rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile


make
compiling client.c
In file included from /Users/javajigi/.rvm/rubies/ruby-1.9.3-p392/include/ruby-1.9.1/ruby.h:32,
                 from ./mysql2_ext.h:8,
                 from client.c:1:
/Users/javajigi/.rvm/rubies/ruby-1.9.3-p392/include/ruby-1.9.1/ruby/ruby.h:105: error: size of array ‘ruby_check_sizeof_long’ is negative
/Users/javajigi/.rvm/rubies/ruby-1.9.3-p392/include/ruby-1.9.1/ruby/ruby.h:109: error: size of array ‘ruby_check_sizeof_voidp’ is negative
In file included from /Users/javajigi/.rvm/rubies/ruby-1.9.3-p392/include/ruby-1.9.1/ruby/intern.h:34,
                 from /Users/javajigi/.rvm/rubies/ruby-1.9.3-p392/include/ruby-1.9.1/ruby/ruby.h:1382,
                 from /Users/javajigi/.rvm/rubies/ruby-1.9.3-p392/include/ruby-1.9.1/ruby.h:32,
                 from ./mysql2_ext.h:8,
                 from client.c:1:
/Users/javajigi/.rvm/rubies/ruby-1.9.3-p392/include/ruby-1.9.1/ruby/st.h:67: error: size of array ‘st_check_for_sizeof_st_index_t’ is negative
client.c: In function ‘rb_raise_mysql2_error’:
client.c:98: warning: ISO C90 forbids mixed declarations and code
client.c: In function ‘rb_mysql_client_socket’:
client.c:590: warning: ISO C90 forbids mixed declarations and code
make:     ** [client.o] Error 1



Gem files will remain installed in /Users/javajigi/.rvm/gems/ruby-1.9.3-p392/gems/mysql2-0.3.11 for inspection.
Results logged to /Users/javajigi/.rvm/gems/ruby-1.9.3-p392/gems/mysql2-0.3.11/ext/mysql2/gem_make.out

Mac에서 ruby on rails를 활용해 mysql과 연결할 때 mysql2 라이브러리를 설치할 때 위와 같은 에러가 발생하는 경우가 있다. 이 경우 다음과 같이 해결할 수 있었다.

HomeBrew가 설치되어 있다는 가정하에서 이다. HomeBrew가 설치되어 있지 않다면 http://mxcl.github.io/homebrew/ 참고해 설치한다.

brew install mysql gem install mysql2 bundle install

내가 정확하게 에러의 원인을 찾을 수는 없지만 대략적으로 유추해보면 mysql에서 제공하는 header 파일을 이용해 빌드를 하는데 버전이 맞지 않아 발생하는 것으로 판단된다. 따라서 먼저 mysql을 다시 설치해 mysql 라이브러리의 버전을 업데이트 한 후에 mysql2 라이브러리를 빌드하는 방식으로 진행하면 된다. 암튼 항상 시스템 설정은 복잡해. 하지만 해결책을 찾고나면 정말 간단히 해결된다는거

0개의 의견 from SLiPP

의견 추가하기

연관태그

← 목록으로