views:

3046

answers:

5

I initiated myself into rails development yesterday.
I installed ruby 1.9.1, rubygems and rails.
Running gem install mongrel worked fine and ostensibly installed mongrel too. I am slightly puzzled because:

  • script/server starts webrick by default
  • which mongrel returns nothing
  • locate mongrel returns lots of entries like
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel
.
.
.
/usr/local/bin/mongrel_rails
/usr/local/lib/ruby/gems/1.9.1/cache/mongrel-1.1.5.gem
/usr/local/lib/ruby/gems/1.9.1/doc/actionpack-2.3.2/rdoc/files/lib/action_controller/vendor/rack-1_0/rack/handler/evented_mongrel_rb.html
/usr/local/lib/ruby/gems/1.9.1/doc/actionpack-2.3.2/rdoc/files/lib/action_controller/vendor/rack-1_0/rack/handler/mongrel_rb.html
/usr/local/lib/ruby/gems/1.9.1/doc/actionpack-2.3.2/rdoc/files/lib/action_controller/vendor/rack-1_0/rack/handler/swiftiplied_mongrel_rb.html
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/handler/evented_mongrel.rb
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/handler/swiftiplied_mongrel.rb
/usr/local/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5
.
.
.

Does look like I have mongrel installed (both the default installation and my custom install). So why doesn't which mongrel return something.

Also trying to reinstall mongrel using gem install mongrel returns throws its own set of exceptions:

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

/usr/local/bin/ruby extconf.rb install mongrel
checking for main() in -lc... yes
creating Makefile

make
gcc -I. -I/usr/local/include/ruby-1.9.1/i386-darwin9.7.0 -I/usr/local/include/ruby-1.9.1/ruby/backward -I/usr/local/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -D_XOPEN_SOURCE=1 -O2 -g -Wall -Wno-parentheses  -fno-common -pipe -fno-common  -o http11.o -c http11.c
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:77: warning: statement with 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 1
A: 

Could this be a compilation issue with ruby 1.9.1 of mongrel? I see some issue with FastThread in 1.9?

atlantis
A: 

It looks like other people are having problems running Mongrel on Ruby 1.9 (http://isitruby19.com/mongrel).

The comment by Ami Mahloof seems like it might be a possible fix.

Olly
+1  A: 

If you just started using ruby on rails don't use ruby 1.9. While rails itself works fine, you will run into lots of issues like this.

Let the old guard figure these out and find out if you even want to work with rails in the first place, then do a production project with it and then give back to the community by trying out unstable versions of gems or rails.

nasmorn
Looks like I should do that. However I was wondering what web server is actually usable with 1.9 .Both mongrel and phusion passenger seem to have issues with fastthread compilation.
atlantis
Passenger certainly can be compiled for 1.9.1 but your mileage may vary. Here is a link about the fastthread patches necessary http://blog.phusion.nl/2009/02/02/getting-ready-for-ruby-191/
nasmorn
JRuby seems to be incompatible with 1.9 for now. Don't seem to have much of an option but to revert to 1.8
atlantis
+1  A: 

it is a compile issue easier to do: git clone git://github.com/mongrel/mongrel.git cd mongrel/ext/http/

edit the http11.c

#ifndef RSTRING_PTR
#define RSTRING_PTR(s) (RSTRING(s))
#endif
#ifndef RSTRING_LEN
#define RSTRING_LEN(s) (RSTRING(s))
#endif

save it from the same directory do sudo ruby extconf.rb && sudo make && sudo make install

Done! Ami Mahloof

+7  A: 

You can install mongrel 1.2 prerelease with sudo gem install mongrel --pre:

$ sudo gem1.9 install mongrel --pre
> Building native extensions.  This could take a while...
> Successfully installed mongrel-1.2.0.pre2
> 1 gem installed
kch
This worked for me, thanks so much!
alvincrespo