2

So I've been using the Odin Project to get started with Web Developing after aimlessly trying to learn for over a year, and I've started downloading everything I need. I own a Windows, so although I've been trying really hard the tide seems to be against me. I'm trying to update rails in the Ruby and Rails command prompt that's downloaded with railsinstaller. I'm not entirely sure of everything so sorry if I sound clueless. Here is the code I keep getting:

C:\Sites>gem install rails --no-ri --no-rdoc
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.

current directory:            C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.7/ext/nokogiri
C:/RailsInstaller/Ruby2.1.0/bin/ruby.exe -r ./siteconf20151206-3704-fzexqt.rb extconf.rb
checking if the C compiler accepts ... *** 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.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=C:/RailsInstaller/Ruby2.1.0/bin/ruby
    --help
    --clean
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The  compiler failed to generate an executable file. (R
You have to install development tools first.
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:571:in `block in   try_compile'
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:522:in `with_werror'
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:571:in `try_compile'
    from extconf.rb:80:in `nokogiri_try_compile'
    from extconf.rb:87:in `block in add_cflags'
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:621:in `with_cflags'
    from extconf.rb:86:in `add_cflags'
    from extconf.rb:336:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/nokogiri-1.6.7/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in     C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.7 for inspection.
Results logged to   C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/nokogiri-1.6.7/gem_make.out

I've looked online and tried to replace my debugger with byebug, not sure if this would have even works but stuff it, tried anyway, didn't work.

I'd really appreciate any help with this, and any advice in general really!

Thanks for reading :)

Here's the contents of the mkmf file,

t.exe -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/i386-mingw32 -  IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/backward -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration  conftest.c  -L. -LC:/RailsInstaller/Ruby2.1.0/lib -L.      -lmsvcrt-ruby210  -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi   "
In file included from C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby.h:33:0,
                 from conftest.c:1:
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h:109:14: error: size of array 'ruby_check_sizeof_voidp' is negative
In file included from C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby.h:33:0,
                 from conftest.c:1:
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h: In function 'rb_obj_wb_unprotect':
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h:1234:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h:1235:6: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h:1238:2: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h: In function 'rb_obj_written':
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h:1253:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h: In function 'rb_num2char_inline':
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h:1324:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h:1324:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h:1324:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h:1325:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h:1325:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h:1325:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h: In function 'rb_class_of':
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h:1642:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h: In function 'rb_type':
C:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/ruby.h:1659:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

Thank you for the suggestion! I can't really make sense of it so any help would be greatly appreciated :)

2 Answers2

1

(I can't comment your question so I write here although is not the answer but a simple suggestion)

Rails installation fails due to lack of necessary libraries and/or headers.

Did you check the file C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/nokogiri-1.6.7/mkmf.log ? Can you update your question with the content of this file?

Here you could find the missing library that Rails gem needs.

Hope it helps.

NickGnd
  • 5,107
  • 1
  • 20
  • 26
0

The error is caused by Nokogiri not having its libraries compiled by Rails.

This is a common problem on Windows - I have written extensively on the topic here.


Nokogiri is a "library" required by Rails.

This means that when you install Rails, it will try and install Nokogiri also (Rails uses it to run).

Unfortunately, Nokogiri is one of a group of gems which require external dependencies to install correctly. When Ruby installs one of these gems, it runs through ext/extconf.rb and runs a compiler to get these dependencies downloaded & installed.

The problem you have is either that your compiler is not working properly, or that you don't have the correct external libraries on your system.

This blog will give you a better understanding of how it works.

-

Windows is notorious for not having the correct libraries for Ruby gems to install, Nokogiri being one of the hardest to get working.

The simplest way to fix it is to install the Nokogiri gem before Rails:

  • Download the appropriate libaries (libxml2, libiconv, libxslt)
  • Run gem install nokogiri --platform=ruby -- --use-system-libraries ...
  • Check the installation and see what happens

The libraries you require are here:

Download these into a folder with no spaces, and then run the following command:

gem install nokogiri --platform=ruby -- --use-system-libraries --with-xml2-dir=c:/path/to/xml2 --with-xslt-dir=c:/path/to/xslt --with-iconv-dir=c:/path/to/iconv

This probably won't install first time - if you come back and let me know what the response is, I'll be in a better position to help.


I understand this might be very high level.

If you want to learn, you should at least try to follow my recommendations. If you want the simpler route, you should look at installing the latest nokogiri (1.6.7):

$ gem install nokogiri -v 1.6.7

This has been tested to install correctly on Windows, and by most accounts it works well.

Community
  • 1
  • 1
Richard Peck
  • 76,116
  • 9
  • 93
  • 147
  • Thank you for your suggestion! I've attempted your recommendation and got the same excomf error but with different libraries etc, shall I edit my original question? Thank you so much for taking the time to help me with this – CharleyBear Dec 07 '15 at 21:02