Related Question: ERROR: Failed to build gem native extension
I am trying to make ruby on rails (ruby 2.0.0p647 (2015-08-18) [x64-mingw32]) to work on my system.
I'm running Windows 8.1 (64 bit)
The installation of ruby and rails goes smoothly but when i run rails new blog
I get the following error:
Installing json 1.8.3 with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
.
C:/Ruby200-x64/bin/ruby.exe extconf.rb
creating Makefile
make "DESTDIR="
generating generator-x64-mingw32.def
compiling generator.c
linking shared-object json/ext/generator.so
c:/ruby200-x64/mingw64/mingw64/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.3/../../.
./../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_s
c:/ruby200-x64/mingw64/mingw64/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.3/../../.
./../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_s
collect2.exe: error: ld returned 1 exit status
make: *** [generator.so] Error 1
Gem files will remain installed in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/json-
1.8.3 for inspection.
Results logged to C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/json-1.8.3/ext/json/ex
t/generator/gem_make.out
Using minitest 5.8.3
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using rack 1.6.4
Using mime-types 2.99
Using arel 6.0.3
Installing debug_inspector 0.0.2 with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
.
I have already tried installing ruby and the development kit 3 times (with different ruby versions)
I keep getting the same error.
I have tried the solution in the question above.
I get a very similar error:
C:\Ruby200-x64>gem install --local json-1.8.3.gem
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing json-1.8.3.gem:
ERROR: Failed to build gem native extension.
C:/Ruby200-x64/bin/ruby.exe extconf.rb
creating Makefile
I have tried to reinstall ruby with different ruby version (the newest one)
as well as installing both of the x86 versions of ruby and the development kit which did nothing for me.
This is not a direct answer because I've not had an issue with JSON before; I'll tell you about the error itself though - just so you know what's going on.
Whenever you install a gem on your system, it needs certain files to run.
Most gems have all the files they need, but some need extra ones. mysql2,rmagick and nokogiri are some of these.
The gems which need extra files have to load "dependencies" from your system to help them install properly. They then compile the extra files with a c compiler. This is what building native extensions means.
When you install any gem, Ruby looks in ext/extconf.rb to see how to compile the extra files. This extconf.rb has compiler code which relies on the dependencies you add. This is why the error always says extconf.rb failed
--
You need a valid C compiler (DevKit includes gcc) and a make program (I believe Devkit includes nmake). Running extconf.rb with Ruby should use the gcc compiler in your PATH to create a Makefile. Running make on the Makefile will then build the gem's extra dependencies:
--
The most common form of this error is for mysql2:
The fix is to include the dependencies on your system, link to it and then install the gem again. EG:
gem install mysql2 --platform=ruby -- --with-mysql-dir="c:/path/to/mysql"
JSON
It seems that JSON just has C headers which need to be compiled.
In this case, I would strongly recommend finding a new compiler & using it instead of Devkit. It might not work, but I think your JSON needs to be compiled rather than have extra dependencies.
We use MingW for compiling things in Windows.
Good ref: https://stackoverflow.com/a/33593870/1143732
You can download our MingW64 here, or download it yourself.
Install it & add it to your PATH. It will take the place of Devkit; its more robust for compiling gems.
Once you've done it, go to your ruby\lib\ruby\gems\[version]\json...\ext
Type ruby extconf.rb and see what happens. If it build a Makefile, type make and then make install
If not, post back what you found and we'll see if it gets fixed
Related
This error occurs when I try to install http_parser using gem:
dongl_000#LENNY ~/ava-home (master)
$ gem install http_parser.rb -v '0.6.0'
Building native extensions. This could take a while...
ERROR: Error installing http_parser.rb:
ERROR: Failed to build gem native extension.
c:/Ruby22-x64/bin/ruby.exe -r ./siteconf20160217-15056-1hoiyfc.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
generating ruby_http_parser-x64-mingw32.def
make: *** No rule to make target '/c/Ruby22-x64/include/ruby-2.2.0/ruby.h', need
ed by 'ruby_http_parser.o'. Stop.
make failed, exit code 2
Gem files will remain installed in c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/http_p
arser.rb-0.6.0 for inspection.
Results logged to c:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0
/http_parser.rb-0.6.0/gem_make.out
How can I resolve this issue?
Versions
ruby : 2.2.1
rubyGem : 2.4.5
I was going through this very same issue.
Looked up the Git Repository for the Gem (HTTP_Parser) and found out the reason for my problem:
HTTP_Parser currently doesn't not support a Path with spaces
So I renamed my path and solved it.
To resolve attempt to add the devkit to Ruby like this:
Install Ruby+DevKit from RubyInstaller: Ruby Window Installers
Downloads
Check the "ridk install" checkbox at the end of the installer.
When RIDK runs, pick option 3 to install both MSYS and MINGW dev tools (make is provided with the MINGW stuff).
Open a fresh console (to get fresh environment variables), and rerun your gem or bundle command...and hope for the best.
I am trying to get Rails working on a Windows system. I installed RubyInstaller and the Devkit, but I cannot seem to get the json gem to install. When I try gem install json I get:
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
make
generating generator-i386-mingw32.def
compiling generator.c
generator.c:1:0: error: CPU you selected does not support x86-64 instruction set
generator.c:1:0: error: CPU you selected does not support x86-64 instruction set
make: *** [generator.o] Error 1
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.3 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.3/ext/json/ext/generator/gem_make.out
It could be my Ruby versions (I have both 2.2 and 1.9), but I do not know. What is going on?
After #Azolo posted his comment, I discovered that the DevKit version I was using did not match the Ruby version I was running. The problem came to be because I needed Ruby 1.9.3 on the path for the Heroku client to function, but was trying to use 2.2 DevKit (as I typically use Ruby 2.2 for development.
I'm on windows and trying to install rails. but I get the following error message:
Z:\AlexL\My Documents\rails>gem install rails
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe -r ./siteconf20150211-3312-5ie7vd.rb extconf.rb
creating Makefile
make clean
Makefile:165: *** target pattern contains no `%'. Stop.
make
Makefile:165: *** target pattern contains no `%'. Stop.
make failed, exit code 2
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.
2 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/extensions/x86-mingw32/1.9.1/js
on-1.8.2/gem_make.out
Ruby version is:
ruby 1.9.3p484
I've got this devkit installed DevKit-tdm-32-4.5.2-20111229-1559-sfx
in this folder:
C:\Ruby193\DevKit\
Not sure what else is wrong?
Looks the same as the issue being discussed here.
Apparently, there is a problem with Ruby 1.9.3 and newer RubyGems versions on Windows machines. Their quick-fix solution was to downgrade to an earlier version of RubyGems.
gem update --system 1.8.29
Once you have done that, confirm that gems -v returns 1.8.29 and try your command again.
Otherwise, you can upgrade to Ruby 2.X, which should also resolve this problem.
I am just getting started with ruby on rails, after installing rails executing many commands on the console, i tried to run rails server with the command rails server but gets an error about not loading coffee-rails, i tried the command gem install coffee-rails i got
gem install coffee-rails
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing coffee-rails:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe -r ./siteconf20140724-4244-v083ym.rb extconf.rb
creating Makefile
make clean
Makefile:165: *** target pattern contains no `%'. Stop.
make
Makefile:165: *** target pattern contains no `%'. Stop.
make failed, exit code 2
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.
1 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/extensions/x86-mingw32/1.9.1/js
on-1.8.1/gem_make.out
RubyGems 2.4.1 will not build native extensions in Ruby version 1.9.3 and earlier on Windows.
You will need to downgrade RubyGems to 1.8.29.
To do this run the following command:
gem update --system 1.8.29
Check gem version:
gem -v
1.8.29
Now try your command again:
gem install coffee-rails
ref: https://groups.google.com/forum/#!topic/rubyinstaller/k19SeJijpKU/discussion
Take a look at this answer - they seem to have had the same trouble and had to use an older version of make.
I'm trying to install sqlite3-ruby on Cygwin with gem install sqlite3-ruby -v x.x.x and I get the following error:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
checking for fdatasync() in -lrt... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Does anyone know how to install sqlite3 for Ruby on Rails on Cygwin. As I understand it the SQLite RubyGem isn't actually a *Ruby*Gem, it's a "*C*Gem", IOW it's written in C. This means it has to be compiled and linked to the Ruby interpreter when you install it, so any help?
So this isn't a complete solution as I don't have a windows box and cygwin handy but the error message suggests that the linux utility fdatasync can't be found.
The tools linux man page can be found here
http://linux.die.net/man/2/fdatasync
Maybe find out if you have fdatasync installed correctly and try again.
I ran into this issue just now – the first time I wanted to install a Ruby gem
on my new Cygwin 64-bit system.
As I understand it the SQLite RubyGem isn't actually a RubyGem, it's a
"CGem", IOW it's written in C. This means it has to be compiled and linked
to the Ruby interpreter when you install it.
Cygwin actually provide a pre-compiled package which installs the sqlite3
gem files including the sqlite3_native.so linked library file. The name of
the package is ruby-sqlite3 and you can install it using Cygwin’s Setup.exe.
I personally like to use apt-cyg
when possible (not always) so I installed the package using:
apt-cyg install ruby-sqlite3
This package installs the appropriate gem files as can be seen by running
cygcheck -l ruby-sqlite3:
/usr/lib/gems/ruby/2.0.0/sqlite3-1.3.9/gem.build_complete
/usr/lib/gems/ruby/2.0.0/sqlite3-1.3.9/sqlite3/sqlite3_native.so
/usr/share/gems/gems/sqlite3-1.3.9/API_CHANGES.rdoc
/usr/share/gems/gems/sqlite3-1.3.9/ChangeLog.cvs
/usr/share/gems/gems/sqlite3-1.3.9/CHANGELOG.rdoc
/usr/share/gems/gems/sqlite3-1.3.9/faq/faq.rb
/usr/share/gems/gems/sqlite3-1.3.9/faq/faq.yml
/usr/share/gems/gems/sqlite3-1.3.9/Gemfile
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/constants.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/database.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/errors.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/pragmas.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/resultset.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/translator.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/value.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/version.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3.rb
/usr/share/gems/gems/sqlite3-1.3.9/LICENSE
/usr/share/gems/gems/sqlite3-1.3.9/Manifest.txt
/usr/share/gems/gems/sqlite3-1.3.9/README.rdoc
/usr/share/gems/gems/sqlite3-1.3.9/tasks/faq.rake
/usr/share/gems/gems/sqlite3-1.3.9/tasks/gem.rake
/usr/share/gems/gems/sqlite3-1.3.9/tasks/native.rake
/usr/share/gems/gems/sqlite3-1.3.9/tasks/vendor_sqlite3