2016-01 / 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
El Capitan から openssl のヘッダファイルが削除されました。ヽ(`Д´)ノプンプン
Homebrew をお使いの方は、eventmachine や puma をインストールしよう
とすると、こんなエラーが発生すると思います。(発生しない方は、すで
に後述のコマンドを実行しているのだと思います。)
make "DESTDIR=" clean make "DESTDIR=" compiling binder.cpp In file included from binder.cpp:20: ./project.h:116:10: fatal error: 'openssl/ssl.h' file not found #include <openssl/ssl.h> ^ 1 error generated. make: *** [binder.o] Error 1 make failed, exit code 2
このコマンドを実行するだけです。
$ brew link openssl --force
/usr/local/include や /usr/local/lib に openssl へのシンボリックリ
ンクが作られ、gem install 可能になります。
Homebrew の openssl がリンクされていますね!
$ otool -L ~/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/eventmachine-1.0.8/ext/rubyeventmachine.bundle /Users/masutaka/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/eventmachine-1.0.8/ext/rubyeventmachine.bundle: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1) /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
openssl の Formula は keg_only なので、インストールしただけではシ
ンボリックリンクが作られないようです。
keg_only の説明は公式のマニュアルにありました。
How to build software outside Homebrew with Homebrew keg-only dependencies. - Homebrew/homebrew
That’s because Homebrew keeps it locked away in its prefix,
accessible only via its opt directory. keg_only = Not symlinked
into the $PATH by default.
ネット上には他のやり方もありましたが、面倒だったり間違っていたりし
たので、ここにまとめておきます。
Need to specify `--with-opt-dir` on OSX 10.11 El Capitan. · Issue #718 · puma/puma
間違ってはいませんが、gem install のたびに指定する必要があり面倒だと思います。
$ gem install eventmachine -- --with-opt-dir=$(brew --prefix openssl)
rbenv-default-gems plugin [2014-10-28-1] にはこのオプションを渡せ
ないので、手動で gem install することになります。
bundle install の時は ~/.bundle/config に以下を追加します。
BUNDLE_BUILD__EVENTMACHINE: "--with-opt-dir=/usr/local/opt/openssl"
ruby - gem eventmachine fatal error: 'openssl/ssl.h' file not found - Stack Overflow
このオプションだけだと、
・ヘッダファイルは Homebrew の openssl を参照し、
・ライブラリはシステムの openssl とリンクしてしまいます。
--with-ldflags=-L$(brew --prefix openssl)/lib も指定しないと、
おかしなことになると思います。
2016-01 / 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
最終更新時間: 2016-01-01 13:53