rake rails:freeze:gems freezes to the wrong version (#7322)

Ticket here: http://dev.rubyonrails.org/ticket/7322

Fix/patch attached.

Internal description:

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 (in /media/prestige/home/ceefour/tmp/halo) Freezing to the gems for Rails 1.4 rm -rf vendor/rails mkdir -p vendor/rails cd vendor/rails Unpacked gem: 'activerecord-1.15.3.7116' mv activerecord-1.15.3.7116 activerecord ERROR: Gem 'rails' not installed. rake aborted! undefined method `to_str' for nil:NilClass

(See full trace by running task with --trace)

Workaround:

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.