Ruby on rails windows:rails:安装bson\U ext时出错

Ruby on rails windows:rails:安装bson\U ext时出错,ruby-on-rails,ruby,mongodb,Ruby On Rails,Ruby,Mongodb,当尝试安装bson_ext时,我看到了错误…安装json gem工作正常,这也需要构建本机扩展-我已经尝试了所有方法,看到了类似的问题,但没有很好的答案 $ gem install bson_ext Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing bson_ext: ERR

当尝试安装bson_ext时,我看到了错误…安装json gem工作正常,这也需要构建本机扩展-我已经尝试了所有方法,看到了类似的问题,但没有很好的答案

$ 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...
根据github上的
,更好的修复方法是将include改为如下:

#ifdef _WIN32
#include <winsock2.h>
#else
#include <arpa/inet.h>
#endif
\ifdef\u WIN32
#包括
#否则
#包括
#恩迪夫

在DevKit上编译时不需要该文件

为了防止此错误,在预期位置创建一个空文件就足够了。如果您的DevKit安装在C:\DevKit中,则该文件应位于C:\DevKit\mingw\include\arpa\inet.h


这也将修复其他原生宝石。原因是,通常来自arpa/inet.h的定义已经来自其他大部分时间自动包含的include文件。

我刚刚将我的gem更新为一个较旧的版本(从2.4.6到2.3),这很有效。

我也有同样的问题。其他人也能够解决类似的问题:
gem update--system;gem install bson_ext
但它对我无效。我已尝试手动安装gem文件,从此处下载该文件:。我得到了与上面相同的错误,表明A)我们都有相同的环境问题,或者B)gem文件有问题。我尝试了gem更新--系统也不适合我:(我尝试了这里提出的解决方案,但仍然没有成功
Use this command
gem update --system 2.3.0