Bundle install: ERROR: Failed to build gem native extension. nio4r gem

gem::ext::builderror: error: failed to build gem native extension.
nio4r gem install error windows
ruby devkit
nio4r gem install error mac
error: error installing rails: error: failed to build gem native extension
ruby download
error: error installing sassc: error: failed to build gem native extension
an error occurred while installing sassc (2.2.1), and bundler cannot continue.

I'm currently working on a project using:

  • rvm 1.26.11
  • ruby 2.2.1p85

I tried to run bundle install but keep getting the following error:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

and, following:

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

When I try running gem install nio4r -v '1.0.0':

Building native extensions.  This could take a while...
ERROR: Error installing nio4r:
ERROR: Failed to build gem native extension.

When I try running bundle update:

Please make sure you have the correct access rights
and the repository exists.
Retrying git clone 'git@github.com:kshmir/requirejs-rails.git' ....*

Git error: command `git clone 'git@github.com:kshmir/requirejs-rails.git'....  has failed

When I try running bundle update nio4r:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension....
An error occurred while installing eventmachine (1.0.3), and Bundler cannot continue.
Make sure that `gem install eventmachine -v '1.0.3'` succeeds before bundling.

I tried that command too, to no result.

I also tried changing Ruby version:

rvm use 2.2.1 2.2.0 2.0.0 and running the commands above, but it doesn't change anything

Edit:

The output from running bundle install log:

Fetching gem metadata from rubygems....... Fetching version metadata from rubygems... Fetching dependency metadata from rubygems.. Using rake 10.2.2 Using i18n
0.7.0 Using multi_json 1.11.0 Using activesupport 3.2.17 Using builder 3.0.4 Using activemodel 3.2.17 Using erubis 2.7.0 Using journey 1.0.4 Using rack 1.4.5 Using rack-cache 1.2 Using rack-test 0.6.2 Using hike
1.2.3 Using tilt 1.4.1 Using sprockets 2.2.2 Using actionpack 3.2.17 Using mime-types 1.25.1 Using polyglot 0.3.4 Using treetop 1.4.15 Using mail 2.5.4 Using actionmailer 3.2.17 Using arbre 1.0.1 Using sass 3.2.19 Using thor 0.19.1 Using bourbon 3.1.8 Using bcrypt 3.1.7 Using bcrypt-ruby 3.1.5 Using orm_adapter 0.5.0 Using rack-ssl 1.3.4 Using json 1.8.1 Using rdoc 3.12.2 Using railties 3.2.17 Using atomic
1.1.15 Using thread_safe 0.2.0 Using warden 1.2.3 Using devise 3.2.3 Using formtastic 2.2.1 Using has_scope 0.6.0.rc Using responders 1.0.0 Using inherited_resources 1.4.1 Using jquery-rails 2.3.0 Using kaminari 0.15.1 Using arel 3.0.3 Using tzinfo 0.3.39 Using activerecord 3.2.17 Using polyamorous 0.5.0 Using meta_search 1.1.3 Using activeresource 3.2.17 Using bundler 1.8.4 Using rails 3.2.17 Using activeadmin 0.6.2 Using rgeo 0.3.20 Using rgeo-activerecord
0.5.0 Using activerecord-postgis-adapter 0.6.5 Using addressable 2.3.5 Using airbrake 3.1.16 Using descendants_tracker 0.0.3 Using ice_nine
0.11.0 Using axiom-types 0.0.5 Using coderay 1.1.0 Using better_errors 1.1.0 Using debug_inspector 0.0.2 Using binding_of_caller 0.7.2 Using bootstrap-datepicker-rails 1.1.1.8 Using bootstrap-sass 3.1.1.0 Using browser 0.8.0 Using columnize 0.3.6 Using debugger-linecache 1.2.0 Using byebug 2.7.0 Using cancan 1.6.10 Using highline 1.6.21 Using net-ssh 2.8.0 Using net-scp 1.1.2 Using net-sftp 2.1.2 Using net-ssh-gateway 1.2.0 Using capistrano 2.15.5 Using mini_portile 0.5.2 Using nokogiri 1.6.1 Using ffi 1.9.3 Using childprocess 0.5.1 Using rubyzip 1.1.0 Using websocket 1.0.7 Using selenium-webdriver 2.40.0 Using xpath 1.0.0 Using capybara 2.0.2 Using carrierwave 0.10.0 Using carrierwave_backgrounder 0.3.0 Using hitimes 1.2.2 Using timers 4.0.1 Using celluloid 0.16.0

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /home/adrian/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150424-28432-11y95op.rb extconf.rb  checking for rb_thread_blocking_region()... no checking for sys/select.h... yes checking for poll.h... yes checking for sys/epoll.h... yes checking for sys/event.h... no checking for port.h... no checking for sys/resource.h... yes creating Makefile

make "DESTDIR=" clean

make "DESTDIR=" compiling selector.c In file included from nio4r.h:10:0,
                 from selector.c:6: /home/adrian/.rvm/rubies/ruby-2.2.1/include/ruby-2.2.0/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h" [-Wcpp] 
#warning use "ruby/io.h" instead of "rubyio.h"   ^ In file included from selector.c:7:0: /home/adrian/.rvm/rubies/ruby-2.2.1/include/ruby-2.2.0/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete [-Wcpp]  #warning rubysig.h is obsolete   ^ selector.c: In function ‘NIO_Selector_allocate’: selector.c:94:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     ev_init(&selector->timer, NIO_Selector_timeout_callback);
     ^ selector.c:94:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] selector.c:94:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] selector.c:99:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     ev_io_init(&selector->wakeup, NIO_Selector_wakeup_callback, selector->wakeup_reader, EV_READ);
     ^ selector.c:99:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] selector.c:99:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] selector.c: In function ‘NIO_Selector_synchronize’: selector.c:159:11: warning: variable ‘current_thread’ set but not used [-Wunused-but-set-variable]
     VALUE current_thread, lock_holder, lock;
           ^ selector.c: In function ‘NIO_Selector_deregister_synchronized’: selector.c:241:11: warning: unused variable ‘monitor_args’ [-Wunused-variable]
     VALUE monitor_args[3];
           ^ selector.c:240:21: warning: unused variable ‘interests’ [-Wunused-variable]
     VALUE self, io, interests, selectables, monitor;
                     ^ selector.c: In function ‘NIO_Selector_select’: selector.c:268:20: warning: unused variable ‘array’ [-Wunused-variable]
     VALUE timeout, array;
                    ^ selector.c: In function ‘NIO_Selector_select_synchronized’: selector.c:286:9: warning: unused variable ‘i’ [-Wunused-variable]
     int i, ready;
         ^ selector.c: In function ‘NIO_Selector_run’: selector.c:326:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     ev_tstamp started_at = ev_now(selector->ev_loop);
     ^ selector.c:341:9: error: ‘TRAP_BEG’ undeclared (first use in this function)
         TRAP_BEG;
         ^ selector.c:341:9: note: each undeclared identifier is reported only once for each function it appears in selector.c:343:9: error: ‘TRAP_END’ undeclared (first use in this function)
         TRAP_END;
         ^ selector.c:347:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
         ev_timer_init(&selector->timer, NIO_Selector_timeout_callback, BUSYWAIT_INTERVAL, BUSYWAIT_INTERVAL);
         ^ selector.c:347:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] selector.c:347:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] selector.c:347:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] selector.c: In function ‘NIO_Selector_close’: selector.c:391:5: warning: passing argument 2 of ‘NIO_Selector_synchronize’ from incompatible pointer type [enabled by default]
     return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
     ^ selector.c:157:14: note: expected ‘VALUE (*)(VALUE *)’ but argument is of type ‘VALUE (*)(VALUE)’  static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE
*args)
              ^ selector.c:391:5: warning: passing argument 3 of ‘NIO_Selector_synchronize’ makes pointer from integer without a cast [enabled by default]
     return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
     ^ selector.c:157:14: note: expected ‘VALUE *’ but argument is of type ‘VALUE’  static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
              ^ selector.c: In function ‘NIO_Selector_closed’: selector.c:407:5: warning: passing argument 2 of ‘NIO_Selector_synchronize’ from incompatible pointer type [enabled by default]
     return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
     ^ selector.c:157:14: note: expected ‘VALUE (*)(VALUE *)’ but argument is of type ‘VALUE (*)(VALUE)’  static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE
*args)
              ^ selector.c:407:5: warning: passing argument 3 of ‘NIO_Selector_synchronize’ makes pointer from integer without a cast [enabled by default]
     return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
     ^ selector.c:157:14: note: expected ‘VALUE *’ but argument is of type ‘VALUE’  static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
              ^ selector.c: In function ‘NIO_Selector_wakeup’: selector.c:384:10: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
     write(selector->wakeup_writer, "\0", 1);
          ^ make: *** [selector.o] Error 1

make failed, exit code 2

Gem files will remain installed in /home/adrian/.rvm/gems/ruby-2.2.1/gems/nio4r-1.0.0 for inspection. Results logged to /home/adrian/.rvm/gems/ruby-2.2.1/extensions/x86_64-linux/2.2.0/nio4r-1.0.0/gem_make.out An error occurred while installing nio4r (1.0.0), and Bundler cannot continue. Make sure that `gem install nio4r -v '1.0.0'` succeeds before bundling.

If you are working on Mac OSX above version 10.11.x, the following approach worked for me:

gem install nio4r -v '1.1.0' -- with-cflags="-std=c99"

Bundle install: ERROR: Failed to build gem native extension. nio4r , If you are working on Mac OSX above version 10.11.x , the following approach worked for me: gem install nio4r -v '1.1.0' -- with-cflags="-std=c99". At work we use the combo "bundle exec && bundle compass watch" or "bundle exec && bundle guard watch" On Apr 22, 2016 11:20 PM, "Will Bowling" will.bowling@weather.com wrote:

[SETUP, RESOLVED] Bundle fails to install `nio4r` · Issue #211 · 18F , gem install nio4r -v '1.2.1' Building native extensions. This could take a while ERROR: Error installing nio4r: ERROR: Failed to build gem  The errors looks like: → gem install nio4r -v '1.2.1' Building native extensions. This could take a while

bundle config build.nio4r --with-cflags="-std=c99"
bundle install

works for me

1817178 – "bundle install" fails to install nio4r gem by , Using bundler 2.1.2 Fetching nio4r 2.5.2 Installing nio4r 2.5.2 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native  I tried also to install it from link, it shows me this: C:\Sites>gem install bundler Fetching: bundler-1.14.6.gem (100%) Successfully installed bundler-1.14.6 Parsing documentation for bundler-1.14.6 Installing ri documentation for bundler-1.14.6 Done installing documentation for bundler after 28 seconds 1 gem installed C:\Sites>rails -v The system cannot find the path specified. @bork

Update to version 1.0.4 if you're using Ruby 2.2.1

Problem with gem nio4r 2.3.1 while installing new plugins , Bundler is installing for ruby but the dependency is only for x86-mingw32 Gem​::Ext::BuildError: ERROR: Failed to build gem native extension. An error occurred while installing nio4r (1.0.0), and Bundler cannot continue. Make sure that gem install nio4r -v '1.0.0' succeeds before bundling.

Setting the bundle config didn't work for me...

If you've recently updated Xcode, make sure to actually run the application and accept the terms of service.

In my bundle error, I was getting You have to install development tools first.

An error occurred while installing nio4r (2.3.1), and Bundler cannot , Fetching nio4r 2.3.1. Installing nio4r 2.3.1 with native extensions. Gem::Ext::​BuildError: ERROR: Failed to build gem native extension. Any idea what I can do here? gem install nio4r -v '1.0.0' Building native extensions. ERROR: Failed to build gem native extension. project and do a bundle

rails 5.0.0 when installing "nio4r": failed to create native gem extension, bundle config build.nio4r --with-cflags="-std=c99". Now you can successfully (​Runtime Error) You must first install the development tools. In the windows you need to install DevKit in order to be able to collect gems. 0. Holger just Jul 20 '16 at  For anyone got the error:"Failed to build gem native extension”, while running sudo gem install rails, and it said somethings about "nokogiri". It is possible because you are using the same ruby version as system is using (for mac user).

ruby, Gem :: Ext :: BuildError: ERROR: Failed to build gem native extension. occurs when bundle install in the current directory of the Rails app . Trying to install a native gem on Windows doesn't work with RubyGems >= 2.4.0, Ruby 1.9.3-p547. DevKit is installed. As far as I can tell, this is related to b97ec2a C:\ruby-1.9.3-p547\bin> gem install json Temporarily enhancing PATH to

“rails new” Not creating a new application, Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/stefan/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/nio4r-2.3.​1/ext/nio4r (RuntimeError) You have to install development tools first. from An error occurred while installing nio4r (2.3.1), and Bundler cannot continue. Make sure 

Comments
  • Do you have libev development files installed? In Ubuntu and derivatives it's libev-dev.
  • @D-side No i didn't, I have them now and still not working..
  • That's awkward. You need to dig around the output and log files to see what's missing. Publishing some snippets may help as well. The weird thing is, I just typed in gem install nio4r and it just worked (Ruby 2.1.5 on RVM). What is it that my machine has that yours doesn't? :\
  • @D-side gem install nio4r worked.. but if I run bundle install again: an error occurred while installing nio4r (1.0.0), and Bundler cannot continue.
  • Logs, sir. We need logs to tell anything significant.
  • worked for me with version 1.0.0 gem install nio4r -v '1.0.0' -- with-cflags="-std=c99"
  • it works! After I upgraded my xcode, it didn't work. Maybe it's because the new Clang. Thank you!
  • Very nice try! Look likes we must install these things again when reinstall OS again.