在Brightbox上通过PPA安装的Ruby 2.1.x上安装Mongrel 1.2.0_pre2的错误

时间:2014-12-08 07:27:41

标签: ruby-on-rails ruby ubuntu mongrel

我继承了Ruby on Rails应用程序代码库,作为新gig的一部分。该代码目前正在生产中,但我负责评估和清理。因此,代码包括Mongrel依赖项;特别是Mogrel 1.2.0_pre2,它可能最后一次在2010年更新,但这就是这段代码所使用的。

本地开发环境在Ubuntu 12.04中运行,并且当我从源代码安装Ruby 2.1.x时,已经通过bundle install成功安装了所有Ruby GEM。

但我最近了解到the Ubuntu ready packages from Brightbox我很激动!我不介意安装表单源,而是宁愿处理软件包安装的清洁度。所以,在一个完全干净的Ubuntu 12.04系统上,我开始重建我的Ruby开发盒,我将PPA添加到我的仓库:

sudo add-apt-repository ppa:brightbox/ruby-ng

更新了本地来源列表:

sudo aptitude update

并安装了他们的Ruby 2.1软件包:

sudo aptitude install ruby2.1 ruby2.1-dev

事情进展顺利,直到bundle install期间,直到Mogrel死于编译错误:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/bin/ruby2.1 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:193:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c:194:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c: In function ‘request_uri’:
http11.c:235:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c: In function ‘fragment’:
http11.c:246:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c: In function ‘request_path’:
http11.c:257:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c: In function ‘query_string’:
http11.c:268:3: error: format not a string literal and no format arguments [-Werror=format-security]
http11.c: In function ‘HttpParser_execute’:
http11.c:439: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

make failed, exit code 2

Gem files will remain installed in /tmp/bundler20141208-21746-1qez12a/mongrel-1.2.0.pre2/gems/mongrel-1.2.0.pre2 for inspection.
Results logged to /tmp/bundler20141208-21746-1qez12a/mongrel-1.2.0.pre2/extensions/x86_64-linux/2.1.0/mongrel-1.2.0.pre2/gem_make.out
An error occurred while installing mongrel (1.2.0.pre2), and Bundler cannot
continue.
Make sure that `gem install mongrel -v '1.2.0.pre2'` succeeds before bundling.

但是运行gem install mongrel -v '1.2.0.pre2'似乎没有帮助;它通过预期的动作然后失败,与通过http11.c完成相同的bundle install错误。

我已经阅读了一些与问题相关的Stack Overflow问题人们已经在Ruby 1.9.2及更高版本中安装了任何版本的Mongrel,例如in this threadin this thread

所有不关注“你应该只使用Thin”的解决方案。谈论手动修补http11.c。但类似引用的this page - 是Ruby 1.9.1和Mongrel 1.1.5,引用的行号肯定与Mogrel_1.2.0pre2中的等价物不对应。

具有讽刺意味的是,一些解决方案实际上指示用户安装Mogrel版本1.2.0pre2而不是1.1.5以解决问题;但我试图安装1.2.0版本的版本,似乎无法完成。

当然我想知道如何克服这个Mongrel错误,所以对此有所帮助将不胜感激。但是为什么当我通过Brightbox PPA安装Ruby 2.1.x时会弹出这个错误,而如果我直接从源代码编译Ruby 2.1.x这个错误根本就不会出现?

1 个答案:

答案 0 :(得分:1)

好的,所以经过一番狩猎之后我偶然发现了一个解决方案,它允许我干净利落 - 无需手动修补 - 在Ruby 2.1.x上安装Mogrel 1.2.0_pre2。解决方案是使用--with-cflags进行GEM的直接Ruby安装,如下所示:

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

一旦我完成了编译,没有问题就完成了,并且成功安装了GEM:

Building native extensions with: '--with-cflags="-O2 -pipe -march=native -w"'
This could take a while...
Successfully installed mongrel-1.2.0.pre2
Parsing documentation for mongrel-1.2.0.pre2
Installing ri documentation for mongrel-1.2.0.pre2
Done installing documentation for mongrel after 1 seconds
1 gem installed

但我仍然想知道为什么在Ruby 2.1.x的纯源代码安装完全没有问题时,通过Brightbox PPA安装Ruby 2.1.x会导致问题。

并非100%清楚--with-cflags=\"-O2 -pipe -march=native -w\"如何影响这一点,但它似乎是一个常见的--with-cflags选项,用于在Ruby版本上安装一些顽固的(可能是过时的?)Ruby GEM比1.9.2。