Ticket here: http://dev.rubyonrails.org/ticket/7322
The rake task uses Gem.cache.search to search 'rails', however this is a partial search which leads to, in my case, 'odbc-rails' gem that has version 1.4. Since there is no Rails 1.4, the task fails.
I marked this as Critical because it has effectively blocked me from using Rails freeze feature for several months already! 'odbc-rails' is "innocently causing" the problem in my system, but any gem having 'rails' in its name has the potential to trigger this bug.
ceefour@ojalanow:/media/prestige/home/ceefour/tmp/halo$ rake rails:freeze:gems
Freezing to the gems for Rails 1.4
rm -rf vendor/rails
mkdir -p vendor/rails
Unpacked gem: 'activerecord-22.214.171.12416'
mv activerecord-126.96.36.19916 activerecord
ERROR: Gem 'rails' not installed.
undefined method `to_str' for nil:NilClass
(See full trace by running task with --trace)
I fixed the task to specify a strict regex specifying /^rails$/i so that rails, and only Rails, will be found by the search. I included 'i' regex modifier in the speculation that other OS (MS's) may somehow use capitalized gem name (???). It's otherwise purely harmless.
Please apply this patch. Thank you.