Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS M1: running rake db:setup fails pointing to ffi gem #948

Open
belgoros opened this issue Apr 8, 2022 · 4 comments
Open

macOS M1: running rake db:setup fails pointing to ffi gem #948

belgoros opened this issue Apr 8, 2022 · 4 comments

Comments

@belgoros
Copy link

belgoros commented Apr 8, 2022

I have the following ffi versions installed:

*** LOCAL GEMS ***

ffi (1.15.5, 1.9.25)
ffi-compiler (1.0.1)
llhttp-ffi (0.3.1)
public_suffix (3.0.3)

I had to install 1.9.25 version as follows:

gem install ffi -v '1.9.25' -- --disable-system-libffi --with-cflags=-Wno-implicit-function-declaration

When running bundle on a project using Ruby 2.7.5 version, everything goes well.
Then, when running rake db:setup it fails as follows:

rake db:setup
/Users/serguei/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/json-1.8.6/lib/json/common.rb:155: warning: Using the last argument as keyword parameters is deprecated
/Users/serguei/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/json-1.8.6/lib/json/common.rb:155: warning: Using the last argument as keyword parameters is deprecated
/Users/serguei/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/json-1.8.6/lib/json/common.rb:155: warning: Using the last argument as keyword parameters is deprecated
/Users/serguei/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/json-1.8.6/lib/json/common.rb:155: warning: Using the last argument as keyword parameters is deprecated
rake aborted!
LoadError: Please add `ffi` to your Gemfile for darwin (macos) machines
dlopen(/Users/serguei/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/ffi-1.9.25/lib/ffi_c.bundle, 0x0009): symbol not found in flat namespace '_ffi_prep_closure' - /Users/serguei/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/ffi-1.9.25/lib/ffi_c.bundle
/Users/serguei/github/rails-app/config/application.rb:20:in `<top (required)>'
/Users/serguei/github/rails-app/Rakefile:5:in `<top (required)>'

Caused by:
LoadError: cannot load such file -- 2.7/ffi_c
/Users/serguei/github/rails-app/config/application.rb:20:in `<top (required)>'
/Users/serguei/github/rails-app/Rakefile:5:in `<top (required)>'

I'm on macOS 12.3.1, Apple M1 chip.

What am I missing?

@karansapolia
Copy link

karansapolia commented Apr 18, 2022

I am facing the same issue

@belgoros
Copy link
Author

belgoros commented Apr 18, 2022

As the Rails app I'm working on, uses ruby 2.7.5 version, I had to install Rosetta terminal as follows:

  • run /usr/sbin/softwareupdate --install-rosetta --agree-to-license
  • In your finder, go to the Applications folder where you will find the Terminal.app
  • Right-click on the copy from the previous step and select Get Info
  • Rename this app Term-x86 and check the box next to Open using Rosetta
  • Exit out of the window to save, then open your new Term-x86
  • To confirm that you configured your Rosetta terminal correctly, enter arch. If it’s configured correctly, it will return i386.

So to have all the dependencies work smoothly in the Rosetta terminal, I also had to install homebrew from inside the Rosetta terminal, because the installation paths are different for M1 and i386 Terminal.

Hope this helps waiting for the fix to come.

@southwolf
Copy link

Hi @belgoros could you please check if my PR can help you with this?
#936
This will try to use arm64 libraries if they are available (installed via arm64 homebrew)

@belgoros
Copy link
Author

belgoros commented May 1, 2022

@southwolf Great work, let's wait for the maintainer to accept and merge the PR 🚀 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants