To install a ancient ffi (<= 1.9.18) in Catalina MacOS or newer OS we need to use this command:

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