On windows, close error command prompt, and run cmd as administrator, then execute gem install rails. the installation is success!