作为新工作的一部分,我继承了 Ruby on Rails 应用程序代码库。该代码目前正在生产中,但我负责评估和清理。因此,代码包含 Mongrel 依赖项;特别是 Mogrel 1.2.0_pre2,它可能最后一次更新是在 2010 年,但这就是这段代码使用的。
本地开发环境在 Ubuntu 12.04 中运行,并已通过 bundle install
成功安装所有 Ruby GEM当我从源代码安装 Ruby 2.1.x 时。
但我最近了解到the Ubuntu ready packages from Brightbox我很激动!我不介意安装表单源,但宁愿处理软件包安装的清洁度。所以,在一个完全干净的 Ubuntu 12.04 系统上,我开始重建我的 Ruby 开发箱,我将 PPA 添加到我的 repo 中:
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'
似乎没有帮助;它通过预期的 Action ,然后以完全相同的http11.c
失败通过 bundle install
执行此操作时的错误.我已经阅读了一些与人们在 Ruby 1.9.2 及更高版本中安装任何版本的 Mongrel 相关的 Stack Overflow 线程,例如 in this thread和 in 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.0pre2 版本,但似乎无法完成。
当然,我想知道如何克服这个 Mongrel 错误,因此将不胜感激。但是为什么当我通过 Brightbox PPA 安装 Ruby 2.1.x 时会弹出此错误,而如果我直接从源代码编译 Ruby 2.1.x 则根本不会出现此错误?
最佳答案
好的,所以在四处寻找之后,我偶然发现了一个解决方案,它允许我在 Ruby 2.1.x 上干净地安装 Mogrel 1.2.0_pre2,而无需手动修补。解决方案是使用 --with-cflags
直接 Ruby 安装 GEM。像这样:
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
用于在高于 1.9.2 的 Ruby 版本上安装一些顽固(可能已经过时?)的 Ruby GEM 的选项。
关于ruby-on-rails - 在通过 Brightbox 的 PPA 安装的 Ruby 2.1.x 上安装 Mongrel 1.2.0_pre2 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27353281/