有没有办法改变gem的gcc编译选项?

我正在努力安装RedCloth gem。 当我打字

gem install RedCloth 

我明白了:

 […] ragel/redcloth_attributes.c.rl: In function 'redcloth_attribute_parser': ragel/redcloth_attributes.c.rl:26:11: error: variable 'act' set but not used [-Werror=unused-but-set-variable] cc1: all warnings being treated as errors make: *** [redcloth_attributes.o] Error 1 […] 

原因是-Rerror编译选项传递给RedCloth gem的extconf.rb中的gcc:

 require 'mkmf' CONFIG['warnflags'].gsub!(/-Wshorten-64-to-32/, '') if CONFIG['warnflags'] $CFLAGS << ' -O0 -Wall -Werror' if CONFIG['CC'] =~ /gcc/ […] 

问题是,当我从文件中删除-Werror选项时,它会在下次启动“gem install”命令时自动重新出现。

如何永久取消设置-Werror选项?


另一个选择是降级到gcc 4.5.2,但它不在我的Fedora 15的存储库中。

我宁愿避免从源代码编译它……

任何帮助非常感谢。

有同样的问题,这是解决方案:

 #gem install RedCloth -- --with-cflags=\"-O2 -pipe -march=native -Wno-unused-but-set-variable\" 

如果您有多个参数,则必须转义引号。

如果您使用的是bundler ,则以下工作方式:

 bundle config build.RedCloth --with-cflags=\"-O2 -pipe -march=native -Wno-unused-but-set-variable\"