Ali and I ran into an interesting Ruby bug on OSX Leopard last week and I thought I’d share the result of our finding….
Basically, we were requesting a 2k RSS feed from a url that had two sub-domains as in:
http://sub1.sub2.example.comThe request worked fine if we hit the server with only one sub-domain as in:
http://sub2.example.comIn the first example, the request would hang for exactly 60 seconds and then return the result. When we tried with a third sub-domain, we got a 120 second hang and then an error.
After digging through the Ruby sources, it looked like the problem was in the TCPSocket C implementation so I threw an email up on the Ruby list.
Turns out the fix is that if you’re trying to use Ruby networking features that sit on top of TCP on OS X Leopard, you may need to add the following to your code:
require 'resolv-replace'Found the fix in this thread.
I also added this line to /usr/lib/ruby/1.8/rubygems.rb (around line 11) and RubyGems is suddenly much, much faster.












