ProTip: Install Rubygems in China

13th May 2016 – 202 words

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.