Today put the version of rails upgrade to 2.2.2 when the following errors happen.
ERROR:  Error installing rails:
        invalid gem format for c:/ruby/lib/ruby/gems/1.8/cache/rails-2.2.2.gem

Put c: / ruby/lib/ruby/gems/1.8/cache/rails-2.2.2.gem delete this file again after the new installation, this time successful.