発生条件
gemのnumoをinstallするときに発生。 numo以外の場合でも発生する可能性があります。
macOSのバージョン
$ sw_vers ProductName: Mac OS X ProductVersion: 10.15.5 BuildVersion: 19F101
rubyのバージョン
$ ruby -v ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
Gem
# Gemfile gem 'numo'
発生したコマンド
対象ディレクトリ内で、下記コマンドを実行した。
$ bundle install
解決方法
brewなどでfftwをインストールする。
brew install fftw
原因
27 │ conftest.c:3:10: fatal error: 'fftw3.h' file not found 28 │ #include <fftw3.h>
'fftw3.h' file not foundですね。
エラー内容
Installing numo-fftw 0.1.1 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/user/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/numo-fftw-0.1.1/ext/numo/fftw /Users/user/.rbenv/versions/2.6.3/bin/ruby -I /Users/user/.rbenv/versions/2.6.3/lib/ruby/2.6.0 -r ./siteconf20200817-9730-1r45s8z.rb extconf.rb checking for numo/narray.h... yes checking for fftw3.h... 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=/Users/user/.rbenv/versions/2.6.3/bin/$(RUBY_BASE_NAME) --with-fftw-dir --without-fftw-dir --with-fftw-include --without-fftw-include=${fftw-dir}/include --with-fftw-lib --without-fftw-lib=${fftw-dir}/lib Header fftw3.h was not found. Give pathname as follows: % ruby extconf.rb --with-fftw-include=header_dir To see why this extension failed to compile, please check the mkmf.log which can be found here: /Users/user/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/numo-fftw-0.1.1/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Users/user/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/numo-fftw-0.1.1 for inspection. Results logged to /Users/user/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/numo-fftw-0.1.1/gem_make.out An error occurred while installing numo-fftw (0.1.1), and Bundler cannot continue. Make sure that `gem install numo-fftw -v '0.1.1' --source 'https://rubygems.org/'` succeeds before bundling.
logを確認
cat /Users/user/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/numo-fftw-0.1.1/gem_make.out 31 │ To see why this extension failed to compile, please check the mkmf.log which ca │ n be found here: 32 │ 33 │ /Users/user/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/extensions/x86_64-darwi │ n-18/2.6.0-static/numo-fftw-0.1.1/mkmf.log
さらに確認
cat /Users/user/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/numo-fftw-0.1.1/mkmf.log 24 │ have_header: checking for fftw3.h... -------------------- no 25 │ 26 │ "clang -E -I/Users/user/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/numo-nar │ ray-0.9.1.8/lib/numo -I/Users/user/.rbenv/versions/2.6.3/include/ruby-2.6.0/x86 │ _64-darwin18 -I/Users/user/.rbenv/versions/2.6.3/include/ruby-2.6.0/ruby/backwa │ rd -I/Users/user/.rbenv/versions/2.6.3/include/ruby-2.6.0 -I. -I/Users/user/.rb │ env/versions/2.6.3/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMI │ TED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statemen │ t -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration │ -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-nor │ eturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializ │ ers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tau │ tological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -We │ xtra-tokens -pipe conftest.c -o conftest.i" 27 │ conftest.c:3:10: fatal error: 'fftw3.h' file not found 28 │ #include <fftw3.h> 29 │ ^~~~~~~~~ 30 │ 1 error generated. 31 │ checked program was: 32 │ /* begin */ 33 │ 1: #include "ruby.h" 34 │ 2: 35 │ 3: #include <fftw3.h> 36 │ /* end */ 37 │
27行目の部分です。
27 │ conftest.c:3:10: fatal error: 'fftw3.h' file not found 28 │ #include <fftw3.h>
'fftw3.h' file not foundなので、fftwをinstallする。
brew install fftw
CPUファンが高速回転し始めた。
保冷剤でPCを冷却しつつ、待つこと20分...
再びコマンド実行
$ bundle install
一応成功しました。が、再びエラーが出ました。
今度は、gslがないようですね。
An error occurred while installing numo-gsl (0.1.2), and Bundler cannot continue. Make sure that `gem install numo-gsl -v '0.1.2' --source 'https://rubygems.org/'` succeeds before bundling.
brew install gsl
今度こそ成功しました。 success!