Building Thin on Win/Ruby 1.9.2: gem install eventmachine --pre
I have to deploy a web application on Windows 2003 Server here at work. Due to a bug I was experiencing with Ruby 1.9.1 I was forced to upgrade the environment to Ruby 1.9.2 (along with DevKit 4.5.0). The applications I write nowadays tend to be based on Sinatra and served by Thin; this application was no different. Thin requires EventMachine, but I had trouble getting it installed.
Attempting to just install the eventmachine gem fails:
C:\>gem install eventmachine Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing eventmachine: ERROR: Failed to build gem native extension. C:/Ruby/bin/ruby.exe extconf.rb checking for rb_trap_immediate in ruby.h,rubysig.h... no checking for rb_thread_blocking_region()... yes checking for inotify_init() in sys/inotify.h... no checking for __NR_inotify_init in sys/syscall.h... no checking for writev() in sys/uio.h... no checking for rb_thread_check_ints()... yes checking for rb_time_new()... yes checking for windows.h... yes checking for winsock.h... yes checking for main() in -lkernel32... yes checking for main() in -lrpcrt4... yes checking for main() in -lgdi32... yes checking for main() in -lssl... no creating Makefile make g++ -I. -IC:/Ruby/include/ruby-1.9.1/i386-mingw32 -I/C/Ruby/include/ruby-1.9.1/ruby/backward -I/C/Ruby/include/ruby-1.9. 1 -I. -DBUILD_FOR_RUBY -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_TBR -DHAVE_RB_THREAD_CHECK_INTS -DHAVE_RB_TIME_NEW -DOS_W IN32 -DHAVE_WINDOWS_H -DHAVE_WINSOCK_H -DWITHOUT_SSL -DHAVE_MAKE_PAIR -O3 -g -Wextra -Wno-unused-parameter -Wno-paren theses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o binder.o -c binder.cpp In file included from project.h:137:0, from binder.cpp:20: binder.h:35:34: warning: type qualifiers ignored on function return type In file included from project.h:138:0, from binder.cpp:20: em.h:91:47: warning: type qualifiers ignored on function return type em.h:92:76: warning: type qualifiers ignored on function return type em.h:93:56: warning: type qualifiers ignored on function return type em.h:95:57: warning: type qualifiers ignored on function return type em.h:96:60: warning: type qualifiers ignored on function return type em.h:97:58: warning: type qualifiers ignored on function return type em.h:98:55: warning: type qualifiers ignored on function return type em.h:99:36: warning: type qualifiers ignored on function return type em.h:101:47: warning: type qualifiers ignored on function return type em.h:106:42: warning: type qualifiers ignored on function return type em.h:123:45: warning: type qualifiers ignored on function return type em.h:132:36: warning: type qualifiers ignored on function return type In file included from project.h:145:0, from binder.cpp:20: eventmachine.h:45:61: warning: type qualifiers ignored on function return type eventmachine.h:46:112: warning: type qualifiers ignored on function return type eventmachine.h:47:69: warning: type qualifiers ignored on function return type eventmachine.h:49:73: warning: type qualifiers ignored on function return type eventmachine.h:62:75: warning: type qualifiers ignored on function return type eventmachine.h:63:74: warning: type qualifiers ignored on function return type eventmachine.h:64:77: warning: type qualifiers ignored on function return type eventmachine.h:65:41: warning: type qualifiers ignored on function return type In file included from project.h:145:0, from binder.cpp:20: eventmachine.h:99:60: warning: type qualifiers ignored on function return type eventmachine.h:100:58: warning: type qualifiers ignored on function return type eventmachine.h:102:60: warning: type qualifiers ignored on function return type eventmachine.h:105:41: warning: type qualifiers ignored on function return type g++ -I. -IC:/Ruby/include/ruby-1.9.1/i386-mingw32 -I/C/Ruby/include/ruby-1.9.1/ruby/backward -I/C/Ruby/include/ruby-1.9.1 -I. -DBUILD_FOR_RUBY -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_TBR -DHAVE_RB_THREAD_CHECK_INTS -DHAVE_RB_TIME_NEW -DOS_WIN32 -DHAVE_WINDOWS_H -DHAVE_WINSOCK_H -DWITHOUT_SSL -DHAVE_MAKE_PAIR -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o cmain.o -c cmain.cpp In file included from project.h:137:0, from cmain.cpp:20: binder.h:35:34: warning: type qualifiers ignored on function return type In file included from project.h:138:0, from cmain.cpp:20: em.h:91:47: warning: type qualifiers ignored on function return type em.h:92:76: warning: type qualifiers ignored on function return type em.h:93:56: warning: type qualifiers ignored on function return type em.h:95:57: warning: type qualifiers ignored on function return type em.h:96:60: warning: type qualifiers ignored on function return type em.h:97:58: warning: type qualifiers ignored on function return type em.h:98:55: warning: type qualifiers ignored on function return type em.h:99:36: warning: type qualifiers ignored on function return type em.h:101:47: warning: type qualifiers ignored on function return type em.h:106:42: warning: type qualifiers ignored on function return type em.h:123:45: warning: type qualifiers ignored on function return type em.h:132:36: warning: type qualifiers ignored on function return type In file included from project.h:145:0, from cmain.cpp:20: eventmachine.h:45:61: warning: type qualifiers ignored on function return type eventmachine.h:46:112: warning: type qualifiers ignored on function return type eventmachine.h:47:69: warning: type qualifiers ignored on function return type eventmachine.h:49:73: warning: type qualifiers ignored on function return type eventmachine.h:62:75: warning: type qualifiers ignored on function return type eventmachine.h:63:74: warning: type qualifiers ignored on function return type eventmachine.h:64:77: warning: type qualifiers ignored on function return type eventmachine.h:65:41: warning: type qualifiers ignored on function return type In file included from project.h:145:0, from cmain.cpp:20: eventmachine.h:99:60: warning: type qualifiers ignored on function return type eventmachine.h:100:58: warning: type qualifiers ignored on function return type eventmachine.h:102:60: warning: type qualifiers ignored on function return type eventmachine.h:105:41: warning: type qualifiers ignored on function return type cmain.cpp:98:71: warning: type qualifiers ignored on function return type cmain.cpp:109:122: warning: type qualifiers ignored on function return type cmain.cpp:119:79: warning: type qualifiers ignored on function return type cmain.cpp:129:83: warning: type qualifiers ignored on function return type cmain.cpp:260:85: warning: type qualifiers ignored on function return type cmain.cpp:270:84: warning: type qualifiers ignored on function return type cmain.cpp:280:88: warning: type qualifiers ignored on function return type cmain.cpp:290:51: warning: type qualifiers ignored on function return type cmain.cpp:300:70: warning: type qualifiers ignored on function return type cmain.cpp:320:55: warning: type qualifiers ignored on function return type cmain.cpp:546:70: warning: type qualifiers ignored on function return type cmain.cpp:669:68: warning: type qualifiers ignored on function return type cmain.cpp: In function 'int evma_send_file_data_to_connection(long unsigned int, const char*)': cmain.cpp:752:6: error: cannot convert 'stat*' to '_stati64*' for argument '2' to 'int _fstati64(int, _stati64*)' make: *** [cmain.o] Error 1 Gem files will remain installed in C:/Ruby/lib/ruby/gems/1.9.1/gems/eventmachine-0.12.10 for inspection. Results logged to C:/Ruby/lib/ruby/gems/1.9.1/gems/eventmachine-0.12.10/ext/gem_make.out
I read on several forum posts that I had to get the latest source from GitHub, but attempting to build the gem there failed (albeit in a different way):
C:\eventmachine>rake build (in C:/eventmachine) cd ext C:/Ruby/bin/ruby.exe extconf.rb checking for rb_trap_immediate in ruby.h,rubysig.h... *** 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:/Ruby/bin/ruby C:/Ruby/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError) You have to install development tools first. from C:/Ruby/lib/ruby/1.9.1/mkmf.rb:446:in `try_compile' from C:/Ruby/lib/ruby/1.9.1/mkmf.rb:568:in `try_var' from C:/Ruby/lib/ruby/1.9.1/mkmf.rb:816:in `block in have_var' from C:/Ruby/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for' from C:/Ruby/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone' from C:/Ruby/lib/ruby/1.9.1/mkmf.rb:254:in `open' from C:/Ruby/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone' from C:/Ruby/lib/ruby/1.9.1/mkmf.rb:254:in `open' from C:/Ruby/lib/ruby/1.9.1/mkmf.rb:276:in `postpone' from C:/Ruby/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for' from C:/Ruby/lib/ruby/1.9.1/mkmf.rb:815:in `have_var' from extconf.rb:16:in `' rake aborted! Command failed with status (1): [C:/Ruby/bin/ruby.exe extconf.rb...] C:/Ruby/lib/ruby/1.9.1/rake.rb:993:in `block in sh' C:/Ruby/lib/ruby/1.9.1/rake.rb:1008:in `call' C:/Ruby/lib/ruby/1.9.1/rake.rb:1008:in `sh' C:/Ruby/lib/ruby/1.9.1/rake.rb:1092:in `sh' C:/Ruby/lib/ruby/1.9.1/rake.rb:1027:in `ruby' C:/Ruby/lib/ruby/1.9.1/rake.rb:1092:in `ruby' C:/eventmachine/Rakefile:148:in `block (3 levels) in ' C:/Ruby/lib/ruby/1.9.1/fileutils.rb:121:in `chdir' C:/Ruby/lib/ruby/1.9.1/fileutils.rb:121:in `cd' C:/Ruby/lib/ruby/1.9.1/rake.rb:1092:in `chdir' C:/eventmachine/Rakefile:147:in `block (2 levels) in ' C:/Ruby/lib/ruby/1.9.1/rake.rb:634:in `call' C:/Ruby/lib/ruby/1.9.1/rake.rb:634:in `block in execute' C:/Ruby/lib/ruby/1.9.1/rake.rb:629:in `each' C:/Ruby/lib/ruby/1.9.1/rake.rb:629:in `execute' C:/Ruby/lib/ruby/1.9.1/rake.rb:595:in `block in invoke_with_call_chain' C:/Ruby/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' C:/Ruby/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain' C:/Ruby/lib/ruby/1.9.1/rake.rb:605:in `block in invoke_prerequisites' C:/Ruby/lib/ruby/1.9.1/rake.rb:602:in `each' C:/Ruby/lib/ruby/1.9.1/rake.rb:602:in `invoke_prerequisites' C:/Ruby/lib/ruby/1.9.1/rake.rb:594:in `block in invoke_with_call_chain' C:/Ruby/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' C:/Ruby/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain' C:/Ruby/lib/ruby/1.9.1/rake.rb:605:in `block in invoke_prerequisites' C:/Ruby/lib/ruby/1.9.1/rake.rb:602:in `each' C:/Ruby/lib/ruby/1.9.1/rake.rb:602:in `invoke_prerequisites' C:/Ruby/lib/ruby/1.9.1/rake.rb:594:in `block in invoke_with_call_chain' C:/Ruby/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' C:/Ruby/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain' C:/Ruby/lib/ruby/1.9.1/rake.rb:605:in `block in invoke_prerequisites' C:/Ruby/lib/ruby/1.9.1/rake.rb:602:in `each' C:/Ruby/lib/ruby/1.9.1/rake.rb:602:in `invoke_prerequisites' C:/Ruby/lib/ruby/1.9.1/rake.rb:594:in `block in invoke_with_call_chain' C:/Ruby/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' C:/Ruby/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain' C:/Ruby/lib/ruby/1.9.1/rake.rb:605:in `block in invoke_prerequisites' C:/Ruby/lib/ruby/1.9.1/rake.rb:602:in `each' C:/Ruby/lib/ruby/1.9.1/rake.rb:602:in `invoke_prerequisites' C:/Ruby/lib/ruby/1.9.1/rake.rb:594:in `block in invoke_with_call_chain' C:/Ruby/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' C:/Ruby/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain' C:/Ruby/lib/ruby/1.9.1/rake.rb:581:in `invoke' C:/Ruby/lib/ruby/1.9.1/rake.rb:2041:in `invoke_task' C:/Ruby/lib/ruby/1.9.1/rake.rb:2019:in `block (2 levels) in top_level' C:/Ruby/lib/ruby/1.9.1/rake.rb:2019:in `each' C:/Ruby/lib/ruby/1.9.1/rake.rb:2019:in `block in top_level' C:/Ruby/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling' C:/Ruby/lib/ruby/1.9.1/rake.rb:2013:in `top_level' C:/Ruby/lib/ruby/1.9.1/rake.rb:1992:in `run' C:/Ruby/bin/rake:31:in ` '
The key to success was given by tmm1
on the #eventmachine
IRC channel (on Freenode.net):
gem install eventmachine --pre
Using the above caused the gem to install without problem, and I was then able to install Thin (gem install thin
) without further incident. I'm told that this should not be necessary 'soon', but for now, there's the answer.