Background:
The global version of ruby on my laptop is 3.1 while this project I was trying to run uses ruby version 2.6.3.
Step 1: Change the version of ruby to 2.63
rbenv shell 2.6.3
Step 2: Install ffi
gem install ffi -v '1.9.17' -- --with-cflags="-Wno-error=implicit-function-declaration"
Problem solved!😄