gem install mongrel与ruby 1.9.1失败

时间:2009-07-02 11:31:19

标签: ruby rubygems mongrel ruby-1.9

我昨天开始进行轨道开发 我安装了ruby 1.9.1,rubygems和rails 运行gem install mongrel运行良好,表面上也安装了mongrel。我有点疑惑,因为:

  • 脚本/服务器默认启动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(默认安装和我的自定义安装)。那么为什么不是哪个杂物会回归呢?

同时尝试使用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

4 个答案:

答案 0 :(得分:47)

您可以使用sudo gem install mongrel --pre安装mongrel 1.2预发行版:

$ sudo gem1.9 install mongrel --pre
> Building native extensions.  This could take a while...
> Successfully installed mongrel-1.2.0.pre2
> 1 gem installed

答案 1 :(得分:5)

在Ruby 1.9上看起来像other people are having problems running Mongrel

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

  

这是你需要做些什么来解决它

     

这是更新的说明:

     

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

     

2)sudo vi / mate on http11.c and:

     

代替第77行      

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

     

代替第172行      

冒号= strchr(RSTRING_PTR(临时),':');

     

代替第174行      

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

     

replce line 176,177

     

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

     

替换第298 299行

     

dptr = RSTRING_PTR(数据);

     

dlen = RSTRING_LEN(数据);

     

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

     

4)sudo ruby​​ extconf.rb&& sudo make&& sudo make install

     

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)修复

中的案例陈述      

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

     

8)sudo gem install gem_plugin(否则mongrel可能挂起)

     

完成!

答案 2 :(得分:3)

这是一个编译问题所以更容易做到这一点:

git clone git://github.com/mongrel/mongrel.git

cd mongrel/ext/http/

现在编辑http11.c

#ifndef RSTRING_PTR
#define RSTRING_PTR(s) (RSTRING(s))
#endif
#ifndef RSTRING_LEN
#define RSTRING_LEN(s) (RSTRING(s))
#endif

保存它,现在从同一目录执行以下操作:

sudo ruby extconf.rb && sudo make && sudo make install

完成!

答案 3 :(得分:2)

你可以像这样强制安装mongrel

sudo gem install mongrel -v 1.2.0.pre2 - --with-cflags = \" -O2 -pipe -march = native -w \"

这解决了这个问题。