The exact error is:
An error occurred while installing nio4r (1.2.1), and bundler cannot continue. Make sure that \'gem install nio4r -v \'1.2.1\'\' succeeds
I resolved the issue by running the following command.
bundle config build.nio4r --with-cflags="-std=c99" bundle