Chunky | Goodness

Building RedCloth With Bundler and GCC 4.6

Getting ready to work on a problem in Rails on an Ubuntu Oneiric (11.10) machine, I ran across the following problem running bundle install for Rails core:

$ bundle install
Updating git://github.com/rails/arel
Updating git://github.com/rails/journey
Fetching source index for http://rubygems.org/
Using rake (0.8.7) 
Installing RedCloth (4.2.7) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/malc/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
checking for main() in -lc... yes
creating Makefile

gcc -I. -I/home/malc/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-linux -I/home/malc/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/home/malc/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I.   -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long  -fPIC -O0 -Wall -Werror  -o redcloth_scan.o -c redcloth_scan.c
gcc -I. -I/home/malc/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-linux -I/home/malc/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/home/malc/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I.   -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long  -fPIC -O0 -Wall -Werror  -o redcloth_inline.o -c redcloth_inline.c
ragel/redcloth_inline.c.rl: In function ‘red_block’:
ragel/redcloth_inline.c.rl:99:9: error: variable ‘attr_regs’ set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors

make: *** [redcloth_inline.o] Error 1

Gem files will remain installed in /home/malc/.gem/ruby/1.9.1/gems/RedCloth-4.2.7 for inspection.
Results logged to /home/malc/.gem/ruby/1.9.1/gems/RedCloth-4.2.7/ext/redcloth_scan/gem_make.out
An error occured while installing RedCloth (4.2.7), and Bundler cannot continue.
Make sure that `gem install RedCloth -v '4.2.7'` succeeds before bundling.

Until this is fixed in RedCloth, you can work around it by specifying extra build options for bundler which will only be applied when building RedCloth:

$ bundle config build.RedCloth --with-cflags=-w

After this bundle install should work as normal.