-
Installing Mongrel with Ruby 1.9
Installing mongrel on ruby 1.9 has caused problems for many different people as has been reported on isitruby19.com.
Running gem install mongrel produces the following error.
http11.c: In function ‘http_field’:
http11.c:77: error: ‘struct RString’ has no member named ‘ptr’
http11.c:77: error: ‘struct RString’ has no member named ‘len’
http11.c:77: warning: left-hand operand of comma expression has no effect
http11.c: In function ‘header_done’:
http11.c:172: error: ‘struct RString’ has no member named ‘ptr’
http11.c:174: error: ‘struct RString’ has no member named ‘ptr’
http11.c:176: error: ‘struct RString’ has no member named ‘ptr’
http11.c:177: error: ‘struct RString’ has no member named ‘len’
http11.c: In function ‘HttpParser_execute’:
http11.c:298: error: ‘struct RString’ has no member named ‘ptr’
http11.c:299: error: ‘struct RString’ has no member named ‘len’
make: *** [http11.o] Error 1To install mongrel after receiving this error, just follow these steps:
1) Switch to the folder to which the gem install put the files, for examplecd /usr/local/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5/ext/http11
2) Edit http11.c with your favourite editor and change these lines to work with ruby 1.9 macros (or download the modified http11.c here, and replace the one created by the gem install:
replace line 77 with:
for(ch = RSTRING_PTR(f), end = ch + RSTRING_LEN(f); ch < end; ch++) {
replace line 172 with:
colon = strchr(RSTRING_PTR(temp), ':');
replace line 174 with:
rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING_PTR(temp)));
replace lines 176,177:
rb_str_substr(temp, colon - RSTRING_PTR(temp)+1, RSTRING_LEN(temp)));
replace lines 298 299:
dptr = RSTRING_PTR(data); dlen = RSTRING_LEN(data);
3) save the file and exit
4) Now run the following from this folder to compile http11.c:
sudo ruby extconf.rb && sudo make && sudo make install
5) Go back to mongrel-1.1.5/ and, as sudo, run:
ruby setup.rb gem build mongrel.gemspec gem install mongrel.gem
6) Fix the case statements in mongrel-1.1.5/lib/mongrel/handlers.rb on lines 208-212, change instances of “: false” to “then false“. Or you can just download the modified handlers.rb here
1 responses to “Installing Mongrel with Ruby 1.9”
-
Thanks for the premade file download links you provided…your post was the most helpful of all.
Leave a reply
-
Y Kamesh Rao September 28th, 2009 at 12:33