Introduction
An error occurred while installing event machine (1.2.3), and Bundler cannot continue. Make sure that gem install eventmachine -v '1.2.3'
succeeds before bundling.
What is the error?
The error message “error failed to build gem native extension” indicates that there was a problem building the native extensions for a Ruby gem. This is usually caused by a mismatch between the Ruby version and the gem version. To fix this, you will need to either downgrade the Ruby version or upgrade the gem.
How to fix the error?
Building native extensions. This could take a while…
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
current directory: /Users/.../.rvm/gems/ruby-2.4.0@global/gems/json-2.0.3/ext/json/ext/generator
/Users/…/.rvm/rubies/ruby-2.4.0/bin/ruby -r ./siteconf20180207-3997-1bfscoz.rb extconf.rb
creating Makefile
current directory: /Users//…/.rvm/gems/ruby-2.4.0@global//gems//json-2.0//ext//json//ext//generator
make “DESTDIR=” clean
current directory: /Users////…/.rvm///gems///////////////ruby-///////////////@global///////////////////////////////////////////////json-///ext////////////////////////////////////////////////////////generator////256////////////////////////////////////////////////rubygems////////////////////////make “DESTDIR=” sh -e environment ENV=production GEM RB_USER_INSTALL=1 RUBYARCHDIR=/Users……/.rvm////gems///////////ruby///lib /Users…………/.rvm////////bin////////gem install json -v ‘2…..’ –user-install extconf failed, exit code 1 Gem files will remain installed in /…./.rvm……. @ global………./.. JSON………./lib for inspection and debugging./.. @ global……Gems../JSON -v 2…………. are installed in.,..1 directory, which is not the current gempathso these gems are not loaded by Rubinius>= 2 . 5 . 8 . Require these gems before bootstrapping for maximum loading speedor run gem env
for more helpbundler: failed to load command : environment ( Bundler :: GemRequireError )LoadError : cannot load such file — rubygems………Require these gems before bootstrapping for maximum loading speed ….or run gem env
for more helpUsing rake 10 . 4 from bundler with bundler ( 1 . 14 ………………..> rake aborted ! ArgumentError : wrong number of arguments ( given 0 , expected 2 ……………..gem require rubygems………Require these gems before bootstrapping for maximum loading speed ….or run gem env
for more helpRubinius >= 2 ……….5 ……………8 …………….advised to upgrade )Tasks : TOP = > defaultFor more information about this error, try ‘rake –help’ rake aborted! No Rakefile found
Conclusion
If you see the error message “Error failed to build gem native extension.” it means that something went wrong while trying to install a Ruby or Rails related gem. The specific message may vary depending on what operating system you are using and which version of Ruby you are using.
The message usually indicates that a required library is missing or that there was a problem compiling the gem. Usually the solution is to install a required package using your system’s package manager (apt, yum, homebrew, etc) or to install a missing development library. If you are trying to install a gem that has C extensions then you will need a C compiler such as GCC installed on your system.
If you are still having problems after following the above instructions then try asking for help on the Ruby on Rails: Talk mailing list or on the #rubyonrails IRC channel on freenode.