ProTip: Install Rubygems in China

1 minute read

Out Of Date Warning

This article was published on 13/05/2016, this means the content may be out of date or no longer relevant.
You should verify that the technical information in this article is still up to date before relying upon it for your own purposes.

If you want to install Gems inside China, unfortunately, you can't use the default website, as you receive a reset:

$ gem install rails                                                                                          AutoShare-Gallery/git/master !
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    Errno::ECONNRESET: Connection reset by peer - SSL_connect (

The Chinese company Taobao provides an up-to-date mirror (15min), that you can use. If you only want to use that mirror for one Gem installation, just use --clear-sources with -s, replacing rails

gem install --clear-sources -s rails

If you plan, on staying longer in China, it might be useful to replace the RubyGems server for the moment:

gem sources --add --remove


Conveniently, bundler has a feature to alias a Gem-server to another one. This way, you can leave your Gemfile source '' at the top of each Gemfile.

Run this command:

bundle config mirror.

To remove the aliasing, just delete the appropriate line in ~/.bundle/config.

On the Taobao Gem-Server there is also some information on how to handle RVM / Ruby installations.