title: How to install and run ffi on M1 Mac
body: <p>I'm using 'ffi', '~&gt; 1.9',</p>
  <p>I'm getting this error when I try to run my rails project</p>
  <pre><code>rake aborted!
  LoadError: dlopen(/Users/kanye.west/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/ffi-1.9.25/lib/ffi_c.bundle, 0x0009): tried: '/Users/kanye.west/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/ffi-1.9.25/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e))) - /Users/kanye.west/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/ffi-1.9.25/lib/ffi_c.bundle
  /Users/kanye.west/dev/anenta/config/application.rb:14:in `&lt;top (required)&gt;'
  /Users/kanye.west/dev/anenta/Rakefile:5:in `require'
  /Users/kanye.west/dev/anenta/Rakefile:5:in `&lt;top (required)&gt;'
  /Users/kanye.west/.rbenv/versions/2.6.9/bin/bundle:23:in `load'
  /Users/kanye.west/.rbenv/versions/2.6.9/bin/bundle:23:in `&lt;main&gt;'
  
  Caused by:
  LoadError: cannot load such file -- 2.6/ffi_c
  /Users/kanye.west/dev/anenta/config/application.rb:14:in `&lt;top (required)&gt;'
  /Users/kanye.west/dev/anenta/Rakefile:5:in `require'
  /Users/kanye.west/dev/anenta/Rakefile:5:in `&lt;top (required)&gt;'
  /Users/kanye.west/.rbenv/versions/2.6.9/bin/bundle:23:in `load'
  /Users/kanye.west/.rbenv/versions/2.6.9/bin/bundle:23:in `&lt;main&gt;'
  (See full trace by running task with --trace)
  
  </code></pre>
  <p>Approaches tried</p>
  <pre><code>gem install --user-install ffi -v '1.9.25' -- --enable-libffi-alloc
  
  gem install ffi -v '1.9.25' -- --with-cflags=&quot;-Wno-error=implicit-function-declaration&quot;
  
  gem install ffi -v '1.9.25' --platform=rub
  
  alias gem=&quot;arch -x86_64 sudo gem&quot;
  
  CFLAGS=&quot;-Wno-error=implicit-function-declaration&quot; RUBY_CONFIGURE_OPTS='--with-readline-dir=/opt/homebrew/opt/readline' gem install ffi -v '1.9.25' -- --with-cflags=&quot;-Wno-error=implicit-function-declaration&quot;
  
  </code></pre>