14

I'm struggling to install the RedCloth gem. When I type

gem install RedCloth

I get :

[…]
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 
[…]

The reason is the -Werror compilation option passed to gcc in the extconf.rb of the RedCloth gem:

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

The problem is that when I remove the -Werror option from the file, it reappears automatically next time I launch the "gem install" command.

How can I permanently unset the -Werror option?


Another option would be to downgrade to gcc 4.5.2, but it's not in the repositories of my Fedora 15.

And I'd rather avoid to compile it from source…

Any help much appreciated.

nimser
  • 620
  • 2
  • 9
  • 22

2 Answers2

25

Had the same problem and here is the solution:

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

You have to escape the quotes if you have more than one argument.

  • 1
    Sweet, it works! Is there a way to put this in the Gemfile so that other people on the project don't have to install the gem separately? – nimser Aug 01 '11 at 21:38
  • I have a similar issue with `gem install rbczmq` caused by an "attributed-deprecated" warning; but passing in `-Wno-deprecated-declarations` did not work. I had to update the actual c header file. – motivic Aug 27 '16 at 14:22
  • Tried to edit this but was rejected, so here goes - @Olivier, it would make sense to prepend the commandline with sudo if you are not using a Ruby version manager like RVM (which makes it possible to install Ruby gems as an unprivileged account). I think it's bad to assume that regular users can install gems; in many cases, this is not true. Maybe that's what you meant with the root prefix #? In that case, I think making this explicit would make sense. – Per Lundberg Oct 03 '18 at 10:55
  • Thanks for the feedback. I've added `sudo` – Olivier - interfaSys Dec 22 '18 at 13:52
  • My feeling is that _escaping_ the double quotes doesn't do anything in this particular case, and indeed I didn't need to do that. I don't have the wherewithal to prove decisively one way or the other, though. – TheDudeAbides Aug 03 '23 at 15:19
16

If you're using bundler, the following works:

bundle config build.RedCloth --with-cflags=\"-O2 -pipe -march=native -Wno-unused-but-set-variable\"
Max Masnick
  • 3,277
  • 2
  • 27
  • 28
  • Yay, this worked for another gem which was missing `linux/inet_diag.h`: `bundle config build.raindrops --with-cflags=\"-I/.../kernel-x.y.z/.../usr/include\"` – l0b0 May 21 '12 at 15:45