【问题标题】:Installing mongrel on cloud9 giving error在cloud9上安装mongrel给出错误
【发布时间】:2015-07-20 04:40:54
【问题描述】:

我正在运行以下命令来安装 mongrel(将应用程序的 ruby​​ 降级到 1.8.7p302,当尝试执行 bundle create --local 时,它要求安装 mysql,然后要求安装 mongrel)

gem install win32-open3 -v '0.3.2'

(master) $ gem install mongrel -v '1.1.5'
Building native extensions.  This could take a while...
ERROR:  Error installing mongrel:
        ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-2.1.5/bin/ruby -r ./siteconf20150509-1034-1akenv5.rb extconf.rb
checking for main() in -lc... yes
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling http11.c
http11.c: In function ‘http_field’:
http11.c:70:3: warning: format not a string literal and no format arguments [-Wformat-security]
   VALIDATE_MAX_LENGTH(flen, FIELD_NAME);
   ^
http11.c:71:3: warning: format not a string literal and no format arguments [-Wformat-security]
   VALIDATE_MAX_LENGTH(vlen, FIELD_VALUE);
   ^
http11.c:77:22: error: ‘struct RString’ has no member named ‘ptr’
   for(ch = RSTRING(f)->ptr, end = ch + RSTRING(f)->len; ch < end; ch++) {
                      ^
http11.c:77:50: error: ‘struct RString’ has no member named ‘len’
   for(ch = RSTRING(f)->ptr, end = ch + RSTRING(f)->len; ch < end; ch++) {
                                                  ^
http11.c:77:27: warning: left-hand operand of comma expression has no effect [-Wunused-value]
   for(ch = RSTRING(f)->ptr, end = ch + RSTRING(f)->len; ch < end; ch++) {
                           ^
http11.c: In function ‘request_uri’:
http11.c:102:3: warning: format not a string literal and no format arguments [-Wformat-security]
   VALIDATE_MAX_LENGTH(length, REQUEST_URI);
   ^
http11.c: In function ‘fragment’:
http11.c:113:3: warning: format not a string literal and no format arguments [-Wformat-security]
   VALIDATE_MAX_LENGTH(length, FRAGMENT);
   ^
http11.c: In function ‘request_path’:
http11.c:124:3: warning: format not a string literal and no format arguments [-Wformat-security]
   VALIDATE_MAX_LENGTH(length, REQUEST_PATH);
   ^
http11.c: In function ‘query_string’:
http11.c:135:3: warning: format not a string literal and no format arguments [-Wformat-security]
   VALIDATE_MAX_LENGTH(length, QUERY_STRING);
   ^
In file included from /usr/include/string.h:635:0,
                 from /usr/local/rvm/rubies/ruby-2.1.5/include/ruby-2.1.0/ruby/defines.h:45,
                 from /usr/local/rvm/rubies/ruby-2.1.5/include/ruby-2.1.0/ruby/ruby.h:29,
                 from /usr/local/rvm/rubies/ruby-2.1.5/include/ruby-2.1.0/ruby.h:33,
                 from http11.c:5:
http11.c: In function ‘header_done’:
http11.c:172:33: error: ‘struct RString’ has no member named ‘ptr’
     colon = strchr(RSTRING(temp)->ptr, ':');
                                 ^
http11.c:172:33: error: ‘struct RString’ has no member named ‘ptr’
     colon = strchr(RSTRING(temp)->ptr, ':');
                                 ^
http11.c:172:33: error: ‘struct RString’ has no member named ‘ptr’
     colon = strchr(RSTRING(temp)->ptr, ':');
                                 ^
http11.c:174:89: error: ‘struct RString’ has no member named ‘ptr’
       rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING(temp)->ptr));
                                                                                         ^
http11.c:176:52: error: ‘struct RString’ has no member named ‘ptr’
           rb_str_substr(temp, colon - RSTRING(temp)->ptr+1, 
                                                    ^
http11.c:177:26: error: ‘struct RString’ has no member named ‘len’
             RSTRING(temp)->len));
                          ^
http11.c: In function ‘HttpParser_execute’:
http11.c:298:23: error: ‘struct RString’ has no member named ‘ptr’
   dptr = RSTRING(data)->ptr;
                       ^
http11.c:299:23: error: ‘struct RString’ has no member named ‘len’
   dlen = RSTRING(data)->len;
                       ^
http11.c:307:5: warning: format not a string literal and no format arguments [-Wformat-security]
     VALIDATE_MAX_LENGTH(http_parser_nread(http), HEADER);
     ^
make: *** [http11.o] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/mongrel-1.1.5 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.1.5@rails4/extensions/x86_64-linux/2.1.0/mongrel-1.1.5/gem_make.out

【问题讨论】:

标签: mysql ruby-on-rails ruby cloud9-ide


【解决方案1】:

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

在 http11.c 上使用 sudo nano 或 vi 并且:

将第 77 行替换为

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

将第 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(数据);

保存文件,

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

去 cd ../../lib/mongrel (或完整路径“/usr/local/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5/lib/mongrel”

sudo nano handlers.rb

修复case语句

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

如果构建失败,那么 sudo gem install mongrel

像这样选择第二个选项

你可以像这样强制安装 mongrel

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

这对我有用,希望对你也有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-05
    • 1970-01-01
    • 1970-01-01
    • 2011-01-31
    • 1970-01-01
    • 1970-01-01
    • 2020-10-01
    • 1970-01-01
    相关资源
    最近更新 更多