Suddenly bundle install is not possible due to gem'ffi'

As the title says. Suddenly bundle install stopped working.

Rails was not Dockerized and was developed in the local environment of mac.

environment

Conclusion

I lowered the version of Xcode installed on my Mac and it passed.

Error message

$ bundle install
.
.
.
Fetching ffi 1.9.23
Installing ffi 1.9.23 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
    current directory: /Users/shimazu/vendor/bundle/ruby/2.5.0/gems/ffi-1.9.23/ext/ffi_c
/Users/shimazu/.rbenv/versions/2.5.0/bin/ruby -I /Users/shimazu/.rbenv/versions/2.5.0/lib/ruby/site_ruby/2.5.0 -r ./siteconf20201102-41899-zc56ao.rb extconf.rb
checking for ffi_call() in -lffi... yes
checking for ffi_closure_alloc()... yes
checking for ffi_raw_call()... yes
checking for ffi_prep_raw_closure()... yes
checking for shlwapi.h... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
checking for ffi_prep_cif_var()... yes
creating extconf.h
creating Makefile
current directory: /Users/shimazu/vendor/bundle/ruby/2.5.0/gems/ffi-1.9.23/ext/ffi_c
make "DESTDIR=" clean
current directory: /Users/shimazu/vendor/bundle/ruby/2.5.0/gems/ffi-1.9.23/ext/ffi_c
make "DESTDIR="
compiling AbstractMemory.c
compiling ArrayType.c
compiling Buffer.c
compiling Call.c
Call.c:334:5: error: implicit declaration of function 'rb_thread_call_without_gvl' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    rbffi_thread_blocking_region(call_blocking_function, data, (void *) -1, NULL);
    ^
./Thread.h:78:39: note: expanded from macro 'rbffi_thread_blocking_region'
# define rbffi_thread_blocking_region rb_thread_call_without_gvl
                                      ^
1 error generated.
make: *** [Call.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/shimazu/vendor/bundle/ruby/2.5.0/gems/ffi-1.9.23 for inspection.
Results logged to /Users/shimazu/vendor/bundle/ruby/2.5.0/extensions/x86_64-darwin-19/2.5.0/ffi-1.9.23/gem_make.out
An error occurred while installing ffi (1.9.23), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.9.23' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
  bootstrap was resolved to 4.0.0, which depends on
    sass was resolved to 3.5.5, which depends on
      sass-listen was resolved to 4.0.0, which depends on
        rb-inotify was resolved to 0.9.10, which depends on
          ffi

Cause

Looking at the error message, it seems that C compilation is failing. .. I tried a lot, but it seemed to be due to the local Xcode version.

before

$ xcodebuild -version
Xcode 12.1
Build version 12A7403

$ clang --version
Apple clang version 12.0.0 (clang-1200.0.32.21)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

after

$ xcodebuild -version
Xcode 11.5
Build version 11E608c

$ clang --version
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Recommended Posts

Suddenly bundle install is not possible due to gem'ffi'
[Note] What to do if bundle install in Chapter 3 of the rails tutorial is not possible
bundle install does not install mysql2
mysql2 fails to install with bundle install
6 points to doubt when user registration is not possible with devise
repository The specified gem is bundle installed but not updated to the latest version
Hot deploy with IntelliJ IDEA
6 points to doubt when user registration is not possible with devise
rails new app is not created with app name
Eclipse does not start after Java 11 is installed
When the project is not displayed in eclipse
Suddenly bundle install is not possible due to gem'ffi'
Error with bundle install after upgrading to Catalina