Error installing nio4r: ERROR: Failed to build gem native extension

I am trying to run one project on my local machine. I installed Ruby and Rails on my Ubuntu OS system. It is working properly. I can create a new project and can run it properly without any error, but when I try to run the existing project it says that we have to bundle install. When I run that command I get the following error:

An error occurred while installing nio4r (2.2.0), and Bundler cannot continue. Make sure that `gem install nio4r -v '2.2.0'` succeeds before bundling.

When I run gem install gem install nio4r -v '2.2.0' it gives me the following error:

Fetching: nio4r-2.2.0.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /var/lib/gems/2.3.0 directory.

1 answer

  • answered 2018-01-14 10:59 Anees Muhammed

    This is just a permission error, you have to use

    sudo bundle install

    or for the specific gem

    sudo gem install nio4r -v '2.2.0'