Friday 18 November 2011

Mongrel gem installation problem in Rails 3 Solved

Sometimes I have seen developers complaining that the 'Mongrel' gem version '1.1.5' has some installation problem when they try it out in Rails 3.

It shows an error something like this:

$ gem install mongrel
Building native extensions.  This could take a while...
ERROR:  Error installing mongrel:
ERROR: Failed to build gem native extension.

        /home/souvikd/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for main() in -lc... yes
creating Makefile
make
gcc -I. -I/home/souvikd/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/i686-linux -I/home/souvikd/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/home/souvikd/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -D_FILE_OFFSET_BITS=64  -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long  -fPIC  -o http11_parser.o -c http11_parser.c
http11_parser.rl: In function ‘http_parser_execute’:
http11_parser.rl:105:3: warning: comparison between signed and unsigned integer expressions
gcc -I. -I/home/souvikd/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/i686-linux -I/home/souvikd/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/home/souvikd/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -D_FILE_OFFSET_BITS=64  -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long  -fPIC  -o http11.o -c http11.c
http11.c: In function ‘http_field’:
http11.c:70:3: warning: format not a string literal and no format arguments
http11.c:71:3: warning: format not a string literal and no format arguments
http11.c:77:22: error: ‘struct RString’ has no member named ‘ptr’
http11.c:77:50: error: ‘struct RString’ has no member named ‘len’
http11.c: In function ‘request_uri’:
http11.c:102:3: warning: format not a string literal and no format arguments
http11.c: In function ‘fragment’:
http11.c:113:3: warning: format not a string literal and no format arguments
http11.c: In function ‘request_path’:
http11.c:124:3: warning: format not a string literal and no format arguments
http11.c: In function ‘query_string’:
http11.c:135:3: warning: format not a string literal and no format arguments
http11.c: In function ‘header_done’:
http11.c:172:13: error: ‘struct RString’ has no member named ‘ptr’
http11.c:172:13: error: ‘struct RString’ has no member named ‘ptr’
http11.c:172:13: error: ‘struct RString’ has no member named ‘ptr’
http11.c:174:89: error: ‘struct RString’ has no member named ‘ptr’
http11.c:176:52: error: ‘struct RString’ has no member named ‘ptr’
http11.c:177:26: error: ‘struct RString’ has no member named ‘len’
http11.c: In function ‘HttpParser_execute’:
http11.c:298:23: error: ‘struct RString’ has no member named ‘ptr’
http11.c:299:23: error: ‘struct RString’ has no member named ‘len’
http11.c:307:5: warning: format not a string literal and no format arguments
make: *** [http11.o] Error 1

Gem files will remain installed in /home/souvikd/.rvm/gems/ruby-1.9.2-p290/gems/mongrel-1.1.5 for inspection.
Results logged to /home/souvikd/.rvm/gems/ruby-1.9.2-p290/gems/mongrel-1.1.5/ext/http11/gem_make.out

Here's what you can do to fix this issue:

1) Go to gemfile.lock and change daemons (1.1.4) to daemons (1.0.10)

[ This previous version of daemons is required to install the Mongrel gem version 1.2.0.pre2 ]

2) Next to update the gem configuration , we run
$ bundle

3) Go to gemfile and add the lines
gem "mongrel", "1.2.0.pre2"

[ This version of the mongrel gem is compatible with Rails 3 ]

4) Again we give bundle command to install the gem
$ bundle

Done!! now you run the rails server and it will boot Mongrel rather than the default WEBrick server.



7 comments: