Windows:Rails:安装bson_ext时出错 [英] windows: rails: error installing bson_ext

查看:57
本文介绍了Windows:Rails:安装bson_ext时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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...

推荐答案

根据此帖子 <arpa/inet.h>不是Windows库,因此应改用winsock2.h.

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**:

  • 转到您的安装文件夹(c:/Ruby193/lib/ruby/gems/1.9.1/gems/bson_ext-1.11.1)
  • 在cbson文件夹中深入研究并找到cbson.c
  • 在您喜欢的文本编辑器中打开cbson.c并找到读取#include "<arpa/inet.h>"
  • 的行.
  • 将该行更改为#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.
  • Go to your installation folder (c:/Ruby193/lib/ruby/gems/1.9.1/gems/bson_ext-1.11.1)
  • Drill down a level into the cbson folder and find cbson.c
  • Open cbson.c in your favorite text editor and find the line that reads #include "<arpa/inet.h>"
  • Change that line to #include winsock2.h
  • Open a command prompt, browse to the installation folder, and run gem build bson_ext.gemspec
  • Move the newly-created .gem file someplace safe (%userprofile%\Desktop, for example).
  • Go up to the gem folder and delete the entire bson_ext folder
  • Back in your command prompt window, change directory to wherever you placed the newly-created .gem file (cd %userprofile%\Desktop, if you're following these steps exactly)
  • Run gem install bson_ext-1.11.1.gem --local and the gem should now install successfully.

**巨大的警告:我只是通过mongodb for rails教程运行,并且没有任何可用来测试此功能的代码.尽管这样可以消除安装错误,但我无法确定此修补程序是否完整.该库参考是1.11.1发行版的新增内容.如果安装版本1.10.2,则不会发生此问题(gem install bson_ext -v 1.10.2).我将由您来决定哪种解决方案对您更有意义.

** 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.

基于对bson-ruby项目进行的更改 github,一个更好的解决办法是更改包含如下内容的内容:

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

这篇关于Windows:Rails:安装bson_ext时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆