gem安装mongrel在ruby 1.9.1下失败。[英] gem install mongrel fails with ruby 1.9.1

本文是小编为大家收集整理的关于gem安装mongrel在ruby 1.9.1下失败。的处理方法,想解了gem安装mongrel在ruby 1.9.1下失败。的问题怎么解决?gem安装mongrel在ruby 1.9.1下失败。问题的解决办法?那么可以参考本文帮助大家快速定位并解决问题。

问题描述

我昨天开始从事 Rails 开发.
我安装了 ruby​​ 1.9.1、rubygems 和 rails.
运行 gem install mongrel 工作正常,表面上也安装了 mongrel.我有点不解,因为:

  • script/server 默认启动 webrick
  • which mongrel 不返回任何内容
  • locate mongrel 返回很多条目,例如
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel
.
.
.
/usr/local/bin/mongrel_rails
/usr/local/lib/ruby/gems/1.9.1/cache/mongrel-1.1.5.gem
/usr/local/lib/ruby/gems/1.9.1/doc/actionpack-2.3.2/rdoc/files/lib/action_controller/vendor/rack-1_0/rack/handler/evented_mongrel_rb.html
/usr/local/lib/ruby/gems/1.9.1/doc/actionpack-2.3.2/rdoc/files/lib/action_controller/vendor/rack-1_0/rack/handler/mongrel_rb.html
/usr/local/lib/ruby/gems/1.9.1/doc/actionpack-2.3.2/rdoc/files/lib/action_controller/vendor/rack-1_0/rack/handler/swiftiplied_mongrel_rb.html
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/handler/evented_mongrel.rb
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/handler/swiftiplied_mongrel.rb
/usr/local/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5
.
.
.

看起来我安装了 mongrel(默认安装和自定义安装).那么为什么 which mongrel 不返回一些东西呢.

还尝试使用 gem install mongrel 返回重新安装 mongrel 会引发其自己的一组异常:

Building native extensions.  This could take a while...
ERROR:  Error installing mongrel:
    ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install mongrel
checking for main() in -lc... yes
creating Makefile

make
gcc -I. -I/usr/local/include/ruby-1.9.1/i386-darwin9.7.0 -I/usr/local/include/ruby-1.9.1/ruby/backward -I/usr/local/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -D_XOPEN_SOURCE=1 -O2 -g -Wall -Wno-parentheses  -fno-common -pipe -fno-common  -o http11.o -c http11.c
http11.c: In function 'http_field':
http11.c:77: error: 'struct RString' has no member named 'ptr'
http11.c:77: error: 'struct RString' has no member named 'len'
http11.c:77: warning: left-hand operand of comma expression has no effect
http11.c:77: warning: statement with no effect
http11.c: In function 'header_done':
http11.c:172: error: 'struct RString' has no member named 'ptr'
http11.c:174: error: 'struct RString' has no member named 'ptr'
http11.c:176: error: 'struct RString' has no member named 'ptr'
http11.c:177: error: 'struct RString' has no member named 'len'
http11.c: In function 'HttpParser_execute':
http11.c:298: error: 'struct RString' has no member named 'ptr'
http11.c:299: error: 'struct RString' has no member named 'len'
make: *** [http11.o] Error 1

推荐答案

看起来像 其他人在 Ruby 1.9 上运行 Mongrel 时遇到问题.

Ami Mahloof 的评论似乎是一个可能的解决方法:

<块引用>

这是你需要做的才能修复它

这是更新后的说明:

1) cd/usr/local/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5/ext/http11

2) http11.c 上的 sudo vi/mate 和:

将第 77 行替换为

for(ch = RSTRING_PTR(f), end = ch + RSTRING_LEN(f); ch < end; ch++) {

将第 172 行替换为

冒号 = strchr(RSTRING_PTR(temp), ':');

将第 174 行替换为

rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, 冒号 - RSTRING_PTR(temp)));

替换第 176,177 行

rb_str_substr(temp, 冒号 - RSTRING_PTR(temp)+1,RSTRING_LEN(temp)));

替换第 298 299 行

dptr = RSTRING_PTR(数据);

dlen = RSTRING_LEN(数据);

3)保存文件,关闭vi/textmate

4) sudo ruby​​ extconf.rb &&须藤制作 &&须藤制作安装

5) cd ../../lib/mongrel(或完整路径"/usr/local/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5/lib/mongrel"

6) mate/sudo vi handlers.rb

7) 修正

中的case语句

在第 208-212 行,将": false"的实例更改为"then false"

8) sudo gem install gem_plugin(否则杂种可能会挂起)

完成!

本文地址:https://www.itbaoku.cn/post/786443.html