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 was with the same error just now.. In my case, I had installed the ruby through the package: https://www.brightbox.com/blog/2017/01/13/ruby-2-4-ubuntu-packages/
But, I had not installed the ruby-dev
package.
In my case: sudo apt-get install ruby2.4-dev
worked for me.
After installation I was able to compile the gem: nio4r
I think you have to install some package ruby-dev
=>
sudo apt-get install ruby-dev