Rubyで、faradayのインストールでエラーがおきました。いろいろ調べて最終的に解消できました。
>gem install faraday-patron
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR: Error installing faraday-patron:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/patron-0.13.3/ext/patron
C:/Ruby31-x64/bin/ruby.exe -I C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0 extconf.rb
checking for curl-config... no
checking for -lcurl... no
*** 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=C:/Ruby31-x64/bin/$(RUBY_BASE_NAME)
--with-curl-dir
--without-curl-dir
--with-curl-include
--without-curl-include=${curl-dir}/include
--with-curl-lib
--without-curl-lib=${curl-dir}/lib
--with-curl-config
--without-curl-config
--with-curllib
--without-curllib
extconf.rb:10:in `<main>': Can't find libcurl or curl/curl.h (RuntimeError)
Try passing --with-curl-config, --with-curl-dir, or --with-curl-lib and --with-curl-include
options to extconf.
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/patron-0.13.3/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/patron-0.13.3 for inspection.
Results logged to C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/patron-0.13.3/gem_make.out
このエラーメッセージは、 patron gem のインストールに失敗したことを示しています。
patron gem が libcurl ライブラリを見つけられないため、ビルドできなかったようです。
libcurl ライブラリがないので、Curlをインストールし、 gem install でその場所を指定すればうまくゆきます。
Windowsでlibcurlをインストールする方法
- curlの公式サイト(https://curl.se/windows/)へ
- 最新バージョンのWindows用バイナリを選択
- ファイルをダウンロード
- ダウンロードしたファイルを解凍(例:C:/curl)
gem install faraday-patronで、curlの場所を指定してインストール
--with-curl-lib と --with-curl-include のスイッチをつけてインストールします。
gem install faraday-patron -- --with-curl-lib="C:/curl/curl-7.88.1-win64-mingw/lib" --with-curl-include="C:/curl/curl-7.88.1-win64-mingw/include"
2023/05/09