在 Ruby 1.9.3 中安装 Mongrel
Posted
技术标签:
【中文标题】在 Ruby 1.9.3 中安装 Mongrel【英文标题】:Install Mongrel in Ruby 1.9.3 【发布时间】:2012-11-30 20:44:47 【问题描述】:如何成功安装 Mongrel for ruby 1.9.3
这是错误:
Building native extensions. This could take a while...
ERROR: Error installing mongrel:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
checking for main() in -lc... yes
creating Makefile
make
compiling http11_parser.c
compiling http11.c
http11.c: In function ‘http_field’:
http11.c:70:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c:71:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c:77:22: error: ‘struct RString’ has no member named ‘ptr’
http11.c:77:50: error: ‘struct RString’ has no member named ‘len’
http11.c:77:27: warning: left-hand operand of comma expression has no effect [-Wunused-value]
http11.c: In function ‘request_uri’:
http11.c:102:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c: In function ‘fragment’:
http11.c:113:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c: In function ‘request_path’:
http11.c:124:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c: In function ‘query_string’:
http11.c:135:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c: In function ‘header_done’:
http11.c:172:13: error: ‘struct RString’ has no member named ‘ptr’
http11.c:172:13: error: ‘struct RString’ has no member named ‘ptr’
http11.c:172:13: error: ‘struct RString’ has no member named ‘ptr’
http11.c:174:89: error: ‘struct RString’ has no member named ‘ptr’
http11.c:176:52: error: ‘struct RString’ has no member named ‘ptr’
http11.c:177:26: error: ‘struct RString’ has no member named ‘len’
http11.c: In function ‘HttpParser_execute’:
http11.c:298:23: error: ‘struct RString’ has no member named ‘ptr’
http11.c:299:23: error: ‘struct RString’ has no member named ‘len’
http11.c:307:5: error: format not a string literal and no format arguments [-Werror=format-security]
cc1: some warnings being treated as errors
make: *** [http11.o] Error 1
Gem files will remain installed in /var/lib/gems/1.9.1/gems/mongrel-1.1.5 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/mongrel-1.1.5/ext/http11/gem_make.out
我已经尝试过sudo gem install mongrel --pre
甚至有--source
的那个
我不知道为什么它不起作用。它与 Ruby 1.9.1 及更高版本兼容吗?
【问题讨论】:
【参考方案1】:You are not alone. 但是,在线程中,有a link to a possible fix。我还没有尝试过,所以 YMMV,但这似乎是一个合理的解决方案。
鉴于 Mongrel 不再更新,为什么不切换到 Thin 之类的东西?
编辑:抱歉,我看到你问的是 1.9.3。我的理解是 Mongrel (应该)与 1.9.1 兼容,但在 1.9.2+ 中被破坏。还有一个很好的理由来切换到更现代和维护的东西。
【讨论】:
【参考方案2】:在命令下,
gem install mongrel --pre
效果很好。
参考:check this link for more details
【讨论】:
【参考方案3】:正如 John B 所说,切换到 Thin。
在无法使用我当前的 Ruby 1.9.3 设置安装 Mongrel 后,我从我的 Gemfile 中注释掉了 Mongrel 并添加了 Thin。这让我的应用完全安装并运行良好。
在我的 Gemfile 中
#gem 'mongrel', '1.2.0.pre2'
gem 'thin'
然后运行
bundle install
【讨论】:
以上是关于在 Ruby 1.9.3 中安装 Mongrel的主要内容,如果未能解决你的问题,请参考以下文章
无法在 Windows 中安装 Nokogiri for Ruby
如何在AWS Lambda函数中安装/使用ruby gems?