Merb 1.0 and Empty reply from server
Yesterday I upgraded merb to 1.0 and I got in some trouble that I solved pretty fast. Last night I started an empty application an got trouble again, but this time for real. I did a fresh install (removed all merb gems and datamapper gems). I generated a fresh merb app with merb-gen but i could not get it to work and all i got from merb was empty replies.
In this post I will try to describe the steps I took to track the problem down and how I solved it.
(I don’t care about this long post so just take me to the solution)
How i generated the app (on a fresh merb install)
Instruction from http://wiki.merbivore.com/howto/gettingstarted/firstapp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | > merb-gen app testapp > cd testapp > merb-gen resource article title:string,content:text > rake db:automigrate > merb Loading init file from /Users/mathias/Documents/Dev/merb/testapp/config/init.rb Loading /Users/mathias/Documents/Dev/merb/testapp/config/environments/development.rb ~ Connecting to database... ~ Loaded slice 'MerbAuthSlicePassword' ... ~ Parent pid: 1239 ~ Compiling routes... ~ Activating slice 'MerbAuthSlicePassword' ... merb : worker (port 4000) ~ Starting Mongrel at port 4000 merb : worker (port 4000) ~ Successfully bound to port 4000 |
Respons from merb
When i point the browser to http://localhost:4000/articles I get the following in the browser
1 2 3 | Safari can’t open the page “http://localhost:4000/articles/”. The error was: “Operation could not be completed. (kCFErrorDomainCFNetwork error 302.)” (kCFErrorDomainCFNetwork:302) Please choose Report Bugs to Apple from the Safari menu, note the error number, and describe what you did before you saw this message. |
Testing the same url with curl i get
1 2 | > curl http://localhost:4000/articles curl: (52) Empty reply from server |
And the only thing i see in the console is the following. No error, no nothing.
1 2 3 | merb : worker (port 4000) ~ Started request handling: Sat Nov 15 20:39:57 +0100 2008 merb : worker (port 4000) ~ Routed to: {"format"=>nil, "action"=>"index", "controller"=>"articles"} merb : worker (port 4000) ~ Params: {"format"=>nil, "action"=>"index", "controller"=>"articles"} |
It seems that merb just drop the connection as soon as it get my request. The following part will be about my debugging.
My effort to solve/debug the problem.
First i followed the steps on http://wiki.merbivore.com/howto/installation/gems#troubleshooting and erased all my merb, datamapper and data_objects gems. Just to get a real clean start.
1 2 3 4 5 6 7 8 | > sudo gem update --system > gem search --no-version merb | grep merb | xargs sudo gem uninstall -a > gem search --no-version dm | grep dm | xargs sudo gem uninstall -a > gem search --no-version data_objects | grep data_objects | xargs sudo gem uninstall -a > sudo gem sources -c > sudo rm /Library/Ruby/Gems/1.8/cache/merb* > sudo rm /Library/Ruby/Gems/1.8/cache/dm* > sudo gem install -r merb |
After this i created a new application but still with the same result. Now my only option was to dig deep in merb to se why i get those empty replies. (I did stop by in #merb and got some suggestions but nothing helped).
I started in merb-core in the Dispatcher. The problem seems to be that merb cannot find any actions in my controllers. It does not raise an “action not found” but the problem points to actions/action args.
Digging deeper I finally find myself in merb-action-args. In the module GetArgs there is a function called get_args and it uses ParseTree to get all action and their arguments. After some simple debugging I found that this is the function that fail.
(Debugging took nearly 2 hours)
1 2 3 4 5 6 | def get_args klass, meth = self.to_s.split(/ /).to_a[1][0..-2].split("#") # Remove stupidity for #<Method: Class(Object)#foo> klass = $` if klass =~ /\(/ ParseTreeArray.translate(Object.full_const_get(klass), meth).get_args end |
The row 5 silently fails.
This make me wonder whats up with my ParseTree installation. Listing my ParseTree gems get me notified of how many versions i have.
1 2 3 4 5 6 7 | Select gem to uninstall: 1. ParseTree-1.7.1 2. ParseTree-2.1.1 3. ParseTree-2.2.0 4. ParseTree-3.0.1 5. ParseTree-3.0.2 6. All versions |
I first try to reinstall ParseTree with sudo gem install ParseTree to reinstall 3.0.2.
The problem still exists so my next step is to uninstall all version and just install the last one.
1 2 3 4 5 6 7 8 9 10 11 12 13 | > sudo gem uninstall ParseTree Select gem to uninstall: 1. ParseTree-1.7.1 2. ParseTree-2.1.1 3. ParseTree-2.2.0 4. ParseTree-3.0.1 5. All versions > 5 > sudo gem install ParseTree Successfully installed ParseTree-3.0.2 1 gem installed |
EVREKA!
This makes merb happy again. Seems like my collection of ParseTree installations made merb unhappy. To get some more understanding of what version made this error i reinstalls all my old versions again, one after one. But after every last one is installed merb still works so there must have been something very wrong with my gems. It shows that i am not alone if you read the comments from a merb 1.0 blog post
Summary
merb relies on other gems than the ones named merb-* in this case ParseTree. So when merb starts delivering empty results. There may be ParseTree thats broken. Just erase all ParseTree version and reinstall the ones you need and maybe you will be as happy as i am
Cheers!

Cheers, thanks for this. I also had to edit the dependency version for data_object to version 0.9.12 in the dependencies.rb. Just thought I’d mention it in case others overlook this step.
bundle
on July 3rd, 2009 at 6:47 am
Thanks for you info bundle!
/mathias
Mathias Stjernström
on July 3rd, 2009 at 8:24 am
That helped, thanks for the write-up!
Jan Kubr
on February 5th, 2010 at 5:22 pm
Thanks for sharing!
/mathias
Mathias Stjernström
on February 5th, 2010 at 9:36 pm
mmkay so I spent the last 20 minutes looking for the same template you’re using and cannot find it. Didn’t want to have to ask but really would love to use it for my site, could you let me know? I’ll check back here soon for any replies. Thanks
Lisandra Schmuck
on December 8th, 2010 at 8:05 am
Hi.
The theme is called Helloblogger –> http://www.easternwest.com/helloblogger-wordpress-theme/
Mathias Stjernström
on December 8th, 2010 at 10:06 am