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

    current directory: C:/Dev/Dependencies/Ruby/ruby-2.2.3-x64-mingw32/lib/ruby/gems/2.2.0/gems/hiredis-0.5.2/ext/hiredis_ext
C:/Dev/Dependencies/Ruby/ruby-2.2.3-x64-mingw32/bin/ruby.exe -r ./siteconf20151222-4124-nisefq.rb extconf.rb
gcc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
net.c:1:0: warning: -fPIC ignored for target (all code is position independent) [enabled by default]
net.c:35:24: fatal error: sys/socket.h: No such file or directory
compilation terminated.
make: *** [net.o] Error 1
*** 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:/Dev/Dependencies/Ruby/ruby-2.2.3-x64-mingw32/bin/$(RUBY_BASE_NAME)
extconf.rb:25:in `block in <main>': Building hiredis failed (RuntimeError)
        from extconf.rb:23:in `chdir'
        from extconf.rb:23:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in C:/Dev/Dependencies/Ruby/ruby-2.2.3-x64-mingw32/lib/ruby/gems/2.2.0/gems/hiredis-0.5.2 for inspection.
Results logged to C:/Dev/Dependencies/Ruby/ruby-2.2.3-x64-mingw32/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/hiredis-0.5.2/gem_make.out
An error occurred while installing hiredis (0.5.2), and Bundler cannot continue.
Make sure that `gem install hiredis -v '0.5.2'` succeeds before bundling.

People say Windows isn't supported, but extconf.rb has an mswin option...

Any ideas on what I should do?

Richard Peck
  • 76,116
  • 9
  • 93
  • 147

1 Answers1

1

The bad news:

hiredis currently does not work on Windows, the Windows specific code is just boilerplate code. Although some work has been done and there are some pull requests (#52 seems to be the most relevant) it looks like it is a hard task.

Unfortunately even that pull request requires compiling with Visual Studio (instead of MinGW) so in the future the binary has to be bundled and shipped with the hiredis Ruby gem. Also the maintainers require a long-term commitment of a maintainer before making hiredis compatible with Windows.

All in all it doesn't look like hiredis can be installed on Windows any time soon.

The good news:

The hiredis gem is a high-performing replacement for the Ruby version of the Redis client. If it cannot be loaded, the slower implementation is used automatically. All you have to do is to force installation of the hiredis gem to fulfill the gem dependencies.

After the failing gem install hiredis call you can write the gem specification manually as described in the gem install documentation:

For example in lib\ruby\gems\2.2.0 you can run:

gem spec cache\hiredis-0.5.2.gem --ruby > specifications\hiredis-0.5.2.gemspec

You'll get a warning when booting up a Rails 5 application, but other than that it should work.

Daniel Rikowski
  • 71,375
  • 57
  • 251
  • 329
  • Thanks for the detailed answer. I got the new 0.6, which installs at least. Rails 5 still depends on `5.2` though... so I got to see how to get that working. – Richard Peck Jan 04 '16 at 21:29