ruby-build で something wrong with LDFLAGS= のエラー
Published at: 2022/12/18
問題
asdf で asdf install ruby 3.1.1
した所、以下のエラーが発生した。
To follow progress, use 'tail -f /var/folders/fk/gwr0gc5s4nd84f58bpp6ts8r0000gn/T/ruby-build.20221218162039.30388.log' or pass --verbose
Downloading openssl-3.0.7.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/83049d042a260e696f62406ac5c08bf706fd84383f945cf21bd61e9ed95c396e
Installing openssl-3.0.7...
Installed openssl-3.0.7 to /Users/user1/.asdf/installs/ruby/3.1.1
Downloading ruby-3.1.1.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.1.tar.gz
Installing ruby-3.1.1...
ruby-build: using readline from homebrew
ruby-build: using gmp from homebrew
BUILD FAILED (macOS 12.3 using ruby-build 20221206)
Inspect or clean up the working tree at /var/folders/fk/gwr0gc5s4nd84f58bpp6ts8r0000gn/T/ruby-build.20221218162039.30388.rn0yW4
Results logged to /var/folders/fk/gwr0gc5s4nd84f58bpp6ts8r0000gn/T/ruby-build.20221218162039.30388.log
Last 10 log lines:
checking for dtrace... dtrace
checking for dot... no
checking for doxygen... no
checking for pkg-config... pkg-config
checking whether it is Android... no
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/user1/.asdf/installs/ruby/3.1.1/lib "
原因
秘伝のタレと化している .zprofile
に、 LIBRARY_PATH
を設定している箇所があった。
これは、昔の ruby-build では、 ruby のビルドにあたり homebrew の openssl を利用していたため、そのパスを指定しなければならなかったころの名残りであった。
Bug #10898: Cannot compile Ruby 2.2.0 with configure error: something wrong with LDFLAGS="" - Ruby master - Ruby Issue Tracking System
Redmine
bugs.ruby-lang.org
上記のリンクにある通り、 LIBRARY_PATH
が空でないと、 ./configure
した際にエラーになる模様。
この環境変数の設定を .zprofile
から削除することで、対応した。
参考
LIBRARY_PATH
blog2.yukii.work