So I take it that you can't even boot the app successfully with ruby ./script/server
? It doesn't start up and then crash on the first request?
When Ruby starts crashing on you, the first thing to look at is whether you are using any binary (not pure Ruby) gems. Just looking at the above list, I believe that json
, mysql
, and rmagick
may be binary. Comment them out temporarily from your Gemfile (if you have to comment out part of the application code, then do it). Try starting the app with bundle exec ruby ./script/server
and see if it crashes. (I think json
might be required by Rails, in which case you won't be able to disable that one.)
If you are only using pure Ruby gems, and Ruby is crashing on you, then you have likely found a bug in the interpreter itself. That's nothing to get scared about; if I was you I would roll my sleeves up, dive into the C source (clone it from github.com/ruby/ruby
), and fix that thang! But if you don't have skills in C you might not want to attempt it.
If you want to try to debug the interpreter, the first thing is to find the point where it is crashing. For that, litter the startup code (such as application.rb
, boot.rb
, etc. with puts "got to #{__FILE__}:#{__LINE__}"
calls and try to pinpoint exactly where the crash is happening. If need be, you can crack open your gems and add puts
calls to them too (just go into the directory where RVM keeps the Ruby code and edit away).
Once you find the point where it is crashing, you can go into the C source and find the implementation of whatever platform method or construct the crash is coming from. To get more information on what is happening internally, add debug printf
calls and recompile the interpreter with make && make install
. (Note that messages from C-level printf
s don't seem to interleave in quite the correct order with Ruby-level puts
.) Temporarily edit your PATH so the newly compiled binary in your cloned ruby/bin
directory will act as the system ruby
.
If you can actually figure the problem out and contribute a patch to Ruby, that will mean some pretty good bragging rights for you!