rbenv install をする際に「configure: error: something wrong with LDFLAGS=......」というエラーが出た際の解決方法の一つ

前提条件

環境は macOS だという前提条件にします。

結論

brew reinstall openssl を実行して openssl を再インストールします。私の場合はこれで解決しました。以下、インストール時のログです。

$ brew reinstall openssl
==> Reinstalling openssl@1.1
==> Downloading https://homebrew.bintray.com/bottles/openssl@1.1-1.1.1d.catalina
Already downloaded: /Users/FOOBAR/Library/Caches/Homebrew/downloads/427c5da28a48eaf91f7d64494c256860757d94dab5687068b5e5958ccbc20a2b--openssl@1.1-1.1.1d.catalina.bottle.tar.gz
==> Pouring openssl@1.1-1.1.1d.catalina.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@1.1/certs

and run
  /usr/local/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because openssl/libressl is provided by macOS so don't link an incompatible version.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

For pkg-config to find openssl@1.1 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

==> Summary
🍺  /usr/local/Cellar/openssl@1.1/1.1.1d: 7,983 files, 17.9MB

補足

  • このエラーが出る状況は様々であると思いますので、上記の方法はあくまでも解決方法の一つです
    • Xcode がらみが原因である可能性がウェブ上では散見されます
  • openssl のインストール後に表示されている、シェルへの環境変数の設定は重要かもしれません*1

参考ページ

github.com

github.com

(参考)rbenv install の失敗時に出るエラーメッセージの一部(最後の10行)

Last 10 log lines:
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for cd using physical directory... cd -P
checking whether CFLAGS is valid... yes
checking whether LDFLAGS is valid... no
configure: error: something wrong with LDFLAGS="-L/Users/FOOBAR/.rbenv/versions/2.7.0/lib "
make: *** No targets specified and no makefile found.  Stop.

*1:私の場合は以前からの既存の設定で問題ありませんでした

Powered by はてなブログ