I'm trying to run bundle install
on my rails 6 app, but I can't successfully compile ffi:
../rescue [manual_assignment|✚15…3] ❯❯❯ bundle install
Fetching https://github.com/rspec/rspec-core
Fetching https://github.com/rspec/rspec-expectations
Fetching https://github.com/rspec/rspec-mocks
Fetching https://github.com/rspec/rspec-rails
Fetching https://github.com/rspec/rspec-support
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies.......
Using rake 13.0.1
Using concurrent-ruby 1.1.7
Using i18n 1.8.5
Using minitest 5.14.2
Using thread_safe 0.3.6
Using tzinfo 1.2.7
Using zeitwerk 2.4.0
Using activesupport 6.0.3.2
Using builder 3.2.4
Using erubi 1.9.0
Using mini_portile2 2.4.0
Using nokogiri 1.10.10
Using rails-dom-testing 2.0.3
Using crass 1.0.6
Using loofah 2.7.0
Using rails-html-sanitizer 1.3.0
Using actionview 6.0.3.2
Using rack 2.2.3
Using rack-test 1.1.0
Using actionpack 6.0.3.2
Using nio4r 2.5.2
Using websocket-extensions 0.1.5
Using websocket-driver 0.7.3
Using actioncable 6.0.3.2
Using globalid 0.4.2
Using activejob 6.0.3.2
Using activemodel 6.0.3.2
Using activerecord 6.0.3.2
Using mimemagic 0.3.5
Using marcel 0.3.3
Using activestorage 6.0.3.2
Using mini_mime 1.0.2
Using mail 2.7.1
Using actionmailbox 6.0.3.2
Using actionmailer 6.0.3.2
Using actiontext 6.0.3.2
Fetching ruby2_keywords 0.0.2
Installing ruby2_keywords 0.0.2
Fetching arbre 1.3.0
Installing arbre 1.3.0
Using formtastic 3.1.5
Using formtastic_i18n 0.6.0
Using has_scope 0.7.2
Using method_source 1.0.0
Using thor 1.0.1
Using railties 6.0.3.2
Using responders 3.0.1
Using inherited_resources 1.11.0
Using jquery-rails 4.4.0
Using kaminari-core 1.2.1
Using kaminari-actionview 1.2.1
Using kaminari-activerecord 1.2.1
Using kaminari 1.2.1
Using polyamorous 2.3.2
Using ransack 2.3.2
Fetching ffi 1.13.1
Installing ffi 1.13.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/jason/.rvm/gems/ruby-2.6.3/gems/ffi-1.13.1/ext/ffi_c
/Users/jason/.rvm/rubies/ruby-2.6.3/bin/ruby -I /Users/jason/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0 -r
./siteconf20200906-62332-1vq6nbs.rb extconf.rb
checking for ffi_prep_closure_loc() in -lffi... 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/jason/.rvm/gems/ruby-2.6.3/gems/ffi-1.13.1/ext/ffi_c
make "DESTDIR=" clean
current directory: /Users/jason/.rvm/gems/ruby-2.6.3/gems/ffi-1.13.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:852:17: error: implicit declaration of function 'ffi_prep_closure_loc' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
ffiStatus = ffi_prep_closure_loc(code, &fnInfo->ffi_cif, callback_invoke, closure, code);
^
Function.c:852:17: note: did you mean 'ffi_prep_closure'?
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/ffi/ffi.h:269:1: note: 'ffi_prep_closure' declared here
ffi_prep_closure(
^
1 error generated.
make: *** [Function.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/jason/.rvm/gems/ruby-2.6.3/gems/ffi-1.13.1 for inspection.
Results logged to /Users/jason/.rvm/gems/ruby-2.6.3/extensions/x86_64-darwin-19/2.6.0/ffi-1.13.1/gem_make.out
An error occurred while installing ffi (1.13.1), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.13.1' --source 'https://rubygems.org/'` succeeds before bundling.
Not sure what the ffi gem does or why I need it, but ActiveAdmin wants it:
In Gemfile:
activeadmin was resolved to 2.8.0, which depends on
sassc-rails was resolved to 2.1.2, which depends on
sassc was resolved to 2.4.0, which depends on
ffi
Any ideas why this is breaking? Thanks to everyone for any help!
Solved by following the steps at https://stackoverflow.com/a/48312139/13217139 then re-installed the gem with gem install ffi -- --enable-system-libffi