windows:rails:安装bson_ext时出错
当试图安装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...
根据这篇文章
不是一个windows库,所以应该使用winsock2.h
。
要更改此引用,我已完成以下**:
- 转到安装文件夹(c:/Ruby193/lib/ruby/gems/1.9.1/gems/bson_ext-1.11.1)
- 向下钻取一个级别进入cbson文件夹并找到cbson.c
- 在您喜欢的文本编辑器中打开cbson.c,找到
#include "
" - 将该行更改为
#include winsock2.h
- 打开命令提示符,浏览到安装文件夹,然后运行
gem build bson_ext.gemspec
- 将新创建的.gem文件移动到安全的位置(例如,%userprofile%\ Desktop)。
- 转到gem文件夹并删除整个bson_ext文件夹
- 回到命令提示符窗口,将目录更改为放置新创建的.gem文件的位置(cd%userprofile%\ Desktop,如果您完全按照这些步骤操作)
- 运行
gem install bson_ext-1.11.1.gem --local
并且gem现在应该成功安装。
**巨大的警告:我刚刚通过mongodb for rails教程,我没有任何可用的代码来测试它。 虽然这消除了安装错误,但我无法确定此修复是否完整。 此库引用是1.11.1版本的新增内容。 如果安装版本1.10.2,则不会发生此问题( gem install bson_ext -v 1.10.2
)。 我会留给你决定哪种解决方案对你更有意义。
编辑:基于对github上的bson-ruby项目的更改,更好的修复方法是更改包括如下所示:
#ifdef _WIN32 #include #else #include #endif
在DevKit上编译时不需要该文件。
要防止出现此错误,只需在预期位置创建一个空文件即可。 如果您的DevKit安装在C:\ DevKit中,则该文件将在C:\ DevKit \ mingw \ include \ arpa \ inet.h中出现。
这也应该修复其他本机gem。 原因是,通常来自arpa / inet.h的定义已经来自大多数时候自动包含的其他包含文件。
Use this command gem update --system 2.3.0
我刚刚将我的gem更新为旧版本(从2.4.6到2.3)并且有效。
- BSON :: ObjectId vs Mongo :: ObjectID
- 如何在Rails 3中并行使用Mongoid和ActiveRecord?
- Mongo :: Error :: OperationFailure:E11000重复键错误集合:metalab_development.demands index:sn_1 dup key:{:null}(11000)
- ActionView :: Template :: Error(在heroku上没有将Fixnum隐式转换为String
- 获得至少一个关联对象的记录
- 连接被拒绝 – 在Mongodb上使用rake db:seed连接(2)
- 如何在mongoid中使用或条件进行查询
- Ruby组按键值散列
- heroku mongohq和mongoid Mongo :: ConnectionFailure