(OS X를 싹 밀지 않고 OS X 업그레이드를 하면 ruby 때문에 좀 힘들 수 있다. )


아래 내용의 후속판이다.

http://knight76.tistory.com/entry/mac-os-%EA%B0%9C%EB%B0%9C%EC%9E%90-%EC%9A%94%EC%84%B8%EB%AF%B8%ED%8B%B0%EC%97%90%EC%84%9C-%EC%97%98%EC%BA%90%ED%94%BC%ED%83%84-os-%EC%97%85%EA%B7%B8%EB%A0%88%EC%9D%B4%EB%93%9C%EC%8B%9C-%ED%8C%81tip


Gemfile에 'gem 'zookeeper', '1.4.11''가 추가되어 

$bundle 실행하면, 아래와 같이 You have to install development tools first. 에러가 발생했다.

링크에 있는데로 최신 Xcode를 깔아도 계속 발생했다.


checking for rb_thread_blocking_region()... *** extconf.rb failed ***

Could not create Makefile due to some reason, probably lack of necessary

libraries and/or headers.  Check the mkmf.log file for more details.  You may

need configuration options.


Provided configuration options:

--with-opt-dir

--without-opt-dir

--with-opt-include

--without-opt-include=${opt-dir}/include

--with-opt-lib

--without-opt-lib=${opt-dir}/lib

--with-make-prog

--without-make-prog

--srcdir=.

--curdir

--ruby=/Users/Samuel/.rbenv/versions/2.1.0/bin/ruby

/Users/Samuel/.rbenv/versions/2.1.0/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)

You have to install development tools first.


gcc 확인했고..

 $ gcc -v

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1

Apple LLVM version 7.0.2 (clang-700.1.81)

Target: x86_64-apple-darwin15.0.0

Thread model: posix


XCode 최신 확인..

$ brew config

..

Xcode: 7.2

..



~/.rbenv/versions/2.1.0/gemsets/story-deploy/gems/zookeeper-1.4.11/ext/mkmf.log 를 참조하니, gcc 4.2를 사용하고 있다.

 $ cat /Users/Samuel/.rbenv//versions/2.1.0/gemsets/story-deploy/gems/zookeeper-1.4.11/ext/mkmf.log

"gcc-4.2 -o conftest -I/Users/Samuel/.rbenv/versions/2.1.0/include/ruby-2.1.0/x86_64-darwin13.0 -I/Users/Samuel/.rbenv/versions/2.1.0/include/ruby-2.1.0/ruby/backward -I/Users/Samuel/.rbenv/versions/2.1.0/include/ruby-2.1.0 -I.   -I/Users/Samuel/.rbenv/versions/2.1.0/gemsets/story-deploy/gems/zookeeper-1.4.11/ext/include  -L/Users/Samuel/.rbenv/versions/2.1.0/gemsets/story-deploy/gems/zookeeper-1.4.11/ext/lib -L/Users/Samuel/.rbenv/versions/2.1.0/lib  -O3 -Wno-error=shorten-64-to-32  -pipe conftest.c  -L/Users/Samuel/.rbenv/versions/2.1.0/gemsets/story-deploy/gems/zookeeper-1.4.11/ext/lib  -L/Users/Samuel/.rbenv/versions/2.1.0/gemsets/story-deploy/gems/zookeeper-1.4.11/ext/lib -L/Users/Samuel/.rbenv/versions/2.1.0/lib -L. -L/Users/Samuel/.rbenv/versions/2.1.0/lib  -fstack-protector     -lruby-static -framework CoreFoundation  -lpthread -ldl -lobjc  -lzookeeper_st_gem -lm"

checked program was:

/* begin */

1: #include "ruby.h"

2:

3: int main(int argc, char **argv)

4: {

5:   return 0;

6: }

/* end */


gcc4.2를 지운 상태라, 당연히 에레가 발생했다.

$ gcc-4.2
-bash: gcc-4.2: command not found




그래서 아래와 같이 gcc42와 libv8을 설치하니 잘 된다.


 $ gem install libv8 -v 3.16.14.7 -- --with-system-v8

Fetching: libv8-3.16.14.7-x86_64-darwin-13.gem (100%)

Successfully installed libv8-3.16.14.7-x86_64-darwin-13

Parsing documentation for libv8-3.16.14.7-x86_64-darwin-13

Installing ri documentation for libv8-3.16.14.7-x86_64-darwin-13

Done installing documentation for libv8 after 0 seconds

1 gem installed


 $ brew install homebrew/dupes/apple-gcc42


$ bundle update

(ok)




정확한 문제의 원인은 잘 모르겠지만, ruby는 gcc-4.2가 반드시 필요하다

운영체제 업그레이드할 때는 일부 라이브러리 컴파일시 gcc-4.2가 안좋을 수 있지만, 

bundle update시 ruby rake가 gcc-4.2를 참조하여 native 컴파일을 하도록 되어 있어서, 상황에 맞게 작업해야 할 듯..



참조

https://gist.github.com/jpodlech/837c7e5103c4cf5cb9b1

https://github.com/cowboyd/therubyracer/issues/304


Posted by '김용환'
,