when trying to install bson_ext i see the error...installing json gem works fine which also requires building native extensions - i have tried everything see similar questions with no good answer
$ gem install bson_ext
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing bson_ext:
ERROR: Failed to build gem native extension.
c:/Ruby193/bin/ruby.exe extconf.rb
checking for asprintf()... no
checking for ruby/st.h... yes
checking for ruby/regex.h... yes
checking for ruby/encoding.h... yes
creating Makefile
make
generating cbson-i386-mingw32.def
compiling bson_buffer.c
compiling cbson.c
cbson.c:25:23: fatal error: arpa/inet.h: No such file or directory
compilation terminated.
make: *** [cbson.o] Error 1
Gem files will remain installed in c:/Ruby193/lib/ruby/gems/1.9.1/gems/bson_ext-
1.11.1 for inspection.
Results logged to c:/Ruby193/lib/ruby/gems/1.9.1/gems/bson_ext-1.11.1/ext/cbson/
gem_make.out
$ gem install json
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed json-1.8.1
1 gem installed
Installing ri documentation for json-1.8.1...
Installing RDoc documentation for json-1.8.1...
According to this post <arpa/inet.h>
is not a windows library, so winsock2.h
should be used instead.
To change this reference, I've done the following**:
#include "<arpa/inet.h>"
#include winsock2.h
gem build bson_ext.gemspec
gem install bson_ext-1.11.1.gem --local
and the gem should now install successfully. ** Huge caveat: I am just running through a mongodb for rails tutorial and I don't have any functioning code with which to test this. While this removes the installation error, I have no way of determining if this fix is a complete one. This library reference is new for the 1.11.1 release. If you install version 1.10.2 this issue will not occur (gem install bson_ext -v 1.10.2
). I'll leave it to you to decide which solution makes more sense for you.
Edit: Based on a change to the bson-ruby project on github, a better fix would be to change that include to read like this:
#ifdef _WIN32
#include <winsock2.h>
#else
#include <arpa/inet.h>
#endif
The file is not needed when compiling on DevKit.
To prevent this error it is enough to create an empty file at the expected location. If your DevKit was installed in C:\DevKit, the file would be expected at C:\DevKit\mingw\include\arpa\inet.h
This should also fix other native gems. The reasons is, that definitions usually coming from arpa/inet.h are already coming from other include files that are automatically included most of the time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With