(1) While bundle install in latest macos, an error message like this occurs:

An error occurred while installing ffi (x.x.x), and Bundler cannot continue

(2) To fix this error, install the gem via the following command:

gem install ffi -v '1.9.18' -- --with-cflags="-Wno-error=implicit-function-declaration"

(3) Run bundle install again.