'Struggling to get rails server running with Mac

Setting up a rails server. When running the following command:

bundle exec rails server

I get the following error:

dlopen(/Users/ben/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/ffi-1.9.25/lib/ffi_c.bundle, 0x0009): symbol not found in flat namespace '_ffi_prep_closure' - /Users/ben/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/ffi-1.9.25/lib/ffi_c.bundle (LoadError)

Any help would be greatly appreciated. Environment: Mac OS X 12.3, CPU: M1 MAX.



Solution 1:[1]

Can You try running following

gem uninstall ffi
brew reinstall libffi
export LDFLAGS="-L/usr/local/opt/libffi/lib"
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
gem install ffi

credits - https://github.com/ffi/ffi/issues/687#issuecomment-468005152

OR

you can try reinstalling gem by

gem install ffi -- --disable-system-libffi

Hope one of these solutions resolve your issue

Thanks.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Abhishek Jadav