ffiインストールエラー対策
bundle installで下記のエラーが出る
1 error generated. make: *** [Function.o] Error 1 make failed, exit code 2 Gem files will remain installed in /Users/inouehiroki/ghq/github.com/SchooLynk/schoolynk-intelligence-api/vendor/bundle/ruby/2.6.0/gems/ffi-1.11.1 for inspection. Results logged to /Users/inouehiroki/ghq/github.com/SchooLynk/schoolynk-intelligence-api/vendor/bundle/ruby/2.6.0/extensions/-darwin-20/2.6.0/ffi-1.11.1/gem_make.out An error occurred while installing ffi (1.11.1), and Bundler cannot continue. Make sure that `gem install ffi -v '1.11.1' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: guard-rspec was resolved to 4.7.3, which depends on guard was resolved to 2.15.1, which depends on listen was resolved to 3.1.5, which depends on rb-inotify was resolved to 0.10.0, which depends on
gem install ffi -v '1.11.1' --source 'https://rubygems.org/'
と言われているので実施する
➜ schoolynk-intelligence-api git:(master) gem install ffi -v '1.11.1' --source 'https://rubygems.org/' Building native extensions. This could take a while... ERROR: Error installing ffi: ERROR: Failed to build gem native extension. current directory: /Users/inouehiroki/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/ffi-1.11.1/ext/ffi_c /Users/inouehiroki/.rbenv/versions/2.6.6/bin/ruby -I /Users/inouehiroki/.rbenv/versions/2.6.6/lib/ruby/2.6.0 -r ./siteconf20210605-43335-vyqlly.rb extconf.rb checking for ffi_call() in -lffi... yes checking for ffi_closure_alloc()... yes checking for shlwapi.h... no checking for rb_thread_call_without_gvl()... yes checking for ruby_native_thread_p()... yes checking for ruby_thread_has_gvl_p()... yes checking for ffi_prep_cif_var()... yes checking for ffi_raw_call()... yes checking for ffi_prep_raw_closure()... yes creating extconf.h creating Makefile current directory: /Users/inouehiroki/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/ffi-1.11.1/ext/ffi_c make "DESTDIR=" clean current directory: /Users/inouehiroki/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/ffi-1.11.1/ext/ffi_c make "DESTDIR=" compiling AbstractMemory.c compiling ArrayType.c compiling Buffer.c compiling Call.c compiling ClosurePool.c compiling DynamicLibrary.c compiling Function.c Function.c:867:17: error: implicit declaration of function 'ffi_prep_closure' is invalid in C99 [-Werror,-Wimplicit-function-declaration] ffiStatus = ffi_prep_closure(code, &fnInfo->ffi_cif, callback_invoke, closure); ^ 1 error generated. make: *** [Function.o] Error 1 make failed, exit code 2 Gem files will remain installed in /Users/inouehiroki/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/ffi-1.11.1 for inspection. Results logged to /Users/inouehiroki/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/-darwin-20/2.6.0/ffi-1.11.1/gem_make.out
Function.c:867:17: error: implicit declaration of function 'ffi_prep_closure' is invalid in C99 [-Werror,-Wimplicit-function-declaration] ffiStatus = ffi_prep_closure(code, &fnInfo->ffi_cif, callback_invoke, closure);
このエラーの対策
export PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig"
参考: