環境
MacOS: 10.12 Sierra
Ruby: 2.1.0
Homebrew: 1.0.8
# 状況
bundle installをすると、gemを入れろと怒られる。
しかし、gemを入れるとgem native extensionのエラーが出る。
>
$ bundle install
An error occurred while installing bcrypt (3.1.11), and Bundler cannot continue.
Make sure thatgem install bcrypt -v '3.1.11'succeeds before bundling.
$ gem install crypt -v ‘3.1.11’
ERROR: Error installing bcrypt:
ERROR: Failed to build gem native extension.
ググると、このエラーでハマる人が結構いる模様。
# 結論
私の場合、**native extensionは罠**でした。
(bundlerを消したり、installしたりするも、行き詰まる。
約5時間格闘...。)
エラー文中の赤や黄色の文字に目を奪われていましたが、
文中に目を移すと以下のエラー。
>
compiling generator.c
couldn't understand kern.osversion `16.0.0'
osversion...
ここで、MacOSをYosemiteからSierraにアップデートしていたことを思い出す。
上記のエラーを検索すると、、、
あったあった、先人の知恵が。
> [`couldn't understand kern.osversion '14.5.0'` でコンパイルエラーするときの対処法](http://qiita.com/d_forest/items/e285d33b047e73ebbfcd)
[OS X Mountain Lion: gcc-4.2 No such file or directory](https://goo.gl/Rs3hKz)
apple-gcc42が悪さをしていた模様。
インストールをし直して、解決!
>
$ brew uninstall apple-gcc42
$ brew install apple-gcc42
# 関連記事
[gem インストール時に発生したエラーとその解決方法まとめ](https://goo.gl/CdvJrO)
[Why won't the bcrypt ruby gem install properly?](https://goo.gl/VZzfKi)