ffi: 1.14.2: missing compatible arch in ffi_c.bundle on M1 Mac mini with system Ruby
I’m trying to build my Github Pages website locally on my M1 mac Mini using this guide. For now, Im trying to create a dummy GitHub Pages site following that guide command by command. However, whenever I execute bundle exec jekyll new --force --skip-bundle .
or bundle exec jekyll serve
, I get the following error:
~/S/jek $ bundle exec jekyll serve
bundler: failed to load command: jekyll (/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/bin/jekyll)
LoadError: dlopen(/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle, 0x0009): missing compatible arch in /Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle - /Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/ffi-1.14.2/lib/ffi.rb:6:in `require'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/ffi-1.14.2/lib/ffi.rb:6:in `rescue in <top (required)>'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/ffi-1.14.2/lib/ffi.rb:3:in `<top (required)>'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:3:in `require'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc/native.rb:3:in `<top (required)>'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc.rb:31:in `require_relative'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc.rb:31:in `<top (required)>'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll/converters/scss.rb:3:in `require'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll/converters/scss.rb:3:in `<top (required)>'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll-sass-converter.rb:4:in `require'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll-sass-converter.rb:4:in `<top (required)>'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/jekyll-4.2.0/lib/jekyll.rb:195:in `require'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/jekyll-4.2.0/lib/jekyll.rb:195:in `<top (required)>'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/jekyll-4.2.0/exe/jekyll:8:in `require'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/gems/jekyll-4.2.0/exe/jekyll:8:in `<top (required)>'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/bin/jekyll:23:in `load'
/Users/venkat/Sites/jek/vendor/bundle/ruby/2.6.0/bin/jekyll:23:in `<top (required)>'
I’m using the system ruby and bundle installed on macOS Big Sur. I’ve tried a bunch of troubleshooting steps – they all seem to point to an issue with ffi-1.14.2 loading the ffi_c.bundle
. Any help would be appreciated.
Happy New Year!
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 22
- Comments: 47 (2 by maintainers)
@venkatasg Have to correct myself, the issue seems to be the version jekyll is depending on. Jekyll still depends on 1.13 while the support for M1 seems to have been implemented in 1.14. Unfortunately it seems the fix is not working as I am still getting the error with the newest version of jekyll which uses 1.14.
For now the only solution seems to be the rosetta workaround:
Install:
arch -arch x86_64 bundle install
Start:arch -arch x86_64 bundle exec jekyll serve
Got it to work by using system ffi :
Running in x86 (Rosetta) mode is not a solution and more a workaround. Native support would be much better.
Apple added deprecation notices to the system Ruby installation starting in 10.15 (Catalina). Fire up
irb
and you’ll see this:I’m not entirely sure how users are supposed to know about this though, I just recall it being reported at the time. Might as well be on display in the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying “Beware of the Leopard.”
@venkatasg you’re “using the system ruby and bundle” which goes against this recommendation and that of the article, which tells you to go to the Ruby site for installation options, not use the preinstalled one. Again I’m not faulting you here, it’s a frustrating/confusing situation for sure when these utilities are “available” but often ancient and/or broken.
~It might be a good idea to update the title of this bug to make abundantly clear we’re talking about the system Ruby installation.~ (update: 👍🏻)
@sanzaru could you provide the script you used? I can help file a radar and share the appropriate Open Radar here if no one is doing that.
Not that I know of. The only “solution” is to install your own ruby (e.g. via Homebrew) and use that. The binary from Apple is deprecated. I wrote an article about my findings, if you’re interested: https://medium.com/better-programming/ruby-on-apple-silicon-m1-macs-fb159849b2f5
I upgraded the Ruby to 3.0.2 with asdf as you can follow steps here.
After that I needed to update bundle,
you can also follow steps described here.
As a result of that
bundle exec jekyll serve
works fine on M1 macAfter playing around a bit I found out that the pre-installed ruby on macOS seems to falsely recognize the CPU as x86, no matter what you tell it to do:
So the problems seems to be more deeply than we thought and we might just have to wait for Apple to update the pre-installed ruby.
Was running similar problems with Flutter and cocoapods. From here, https://github.com/flutter/flutter/wiki/Developing-with-Flutter-on-Apple-Silicon the following worked for me:
sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc
That’s interesting. I didn’t know about this warning at all. Could be more transparent for devs…
Of course. It was quite simple:
I found out that the RbConfig module (rbconfig.rb) seems to be the problem as it was compiled for x86 and therefore always returns that value when reading the module. Hope I can publish a detailed article about that, soon.
I guess we need to file a Feedback/Radar with Apple then? I might get around to it sometime, but I’ve never gotten any response on any of the feedbacks I’ve filed thus far, so I’ve learnt never to place high trust in that.
Should I close this issue?
For me, it seems that I got 2 different versions of ffi and it was choosing the bad one so first uninstall both:
sudo gem uninstall ffi
Then proceed with the above.On my M1, I enabled rosetta on xcode and terminal, to support older projects. Then had to do this:
PS: I’m using cocoapods from gem and not from brew.
It seems one solution is to run whole terminal in Rosetta mode (go to apps -> tools -> terminal -> right click -> get info -> open using rosetta) and then install everything in that mode (I use XCode in rosetta and that works for my mobile dev env) - but personally I gave up on that idea - you have to juggle with
arch
and it’s becomes a pain quickly - and simply started running M1-incompatbile projects in docker container via docker compose - there is already m1 tech previews available and it’s pretty stable; everything else - I try to install natively - if it breaks - docker to the rescue; my 2-cents-workaround 🤷I had these issue a few minutes ago. Sound weird, but the solution was to start Xcode. I updated Xcode a few days ago and the licence had to be acknoledged, after that I could run
bundle install
and ffi was installed without any issues.This did the trick for me! Thanks Stef!
I had an existing Jekyll project that hit the ffi issue. It was already placing all code into vendor/bundle
I was able to install a new libffi with brew, setup things to use it rather than the system version, and then the bundle install succeeded (which included the ffi gem).
from an Above comment :
This worked for me! here’s how…
I’m using an Apple M1 Mac Mini , running Big Sur 11.6
some notes on the solution:
It was important for me to realize I was using zsh now, instead of Bash like I was used to on my old Mac laptop. This is a new default, so I installed Oh My Zsh to make things easier going forward for myself. ymmv.
Homebrew installation of ruby did me dirty because there was a command that is supposed to update the $PATH, but it wasn’t working.
This was due to homebrew some how, I forget now sorry I should have noted it… but anyways, I uninstalled the home-brew version of ruby.
No matter what with this home-brew version, when I typed
ruby -v
, it would tell me that I am using the 2.x.x version not the 3.x.x. This is the Mac OS default ruby version.So I installed a fresh ruby after deleting the home-brew ruby.
which ruby
where ruby
helped me here. It went from being in thesomething/homebrew/something/ruby
location to theusr / myname / ruby
location. Fresh install confirmed.The next hurdle was how to tell the system to use this 3.x x version of ruby by default and not the 2.x.x oldie one.
For this, I installed a ‘manager’ called ‘asdf’, which allowed me to fix the issues with my $PATH. After following the asdf install instructions, what worked in the end was running
asdf reshim ruby
.Then when I typed
ruby -v
it showed the correctt 3.x.x version. Hurray.Then, with ruby working, I moved on to jekyll.
I followed this advice to uninstall my accidental jekyll installs just to start fresh to not mess myself up somehow. turns out I had a few extra installs so I nuked them all and followed the generic instructions to get my fresh install. I thought everything was done right but then I encountered this thread’s main topic, the issue with the m1 chip.
So after having installed jekyll, then
Jekyll new mysitename
, thencd mysitename
then
then
bundle exec jekyll serve
WORKED!!!Thank you 😃
@mkocus: At least as of 2021-06-21: if you make sure to install ruby from homebrew, and make sure
PATH
points to this newer version of ruby (rather than the binary installed by default on macOS), installing packages that make use of ffi should work just fine. (At least I have not run into any problems).You can put it in a file (e.g. call it
arch.rb
) and then runruby arch.rb
to get the results.What’s so frustrating is some say that everything works fine, but don’t say whether they used the solution and/or workaround they used. So it’s been very frustrating. I was hoping for a constructive reply, but dismayed that even though I clearly said “in x86_64 mode” you’d have some subjective semantical objection to a word in the previous sentence. Anyway, it’s hard to tell if anyone has it working natively or not.
Any idea if there’s work on to fix it in the near future? I wish I could help, but I’m not familiar with this low level stuff at all.