[Ruby on Rails (RoR)] Use RubyGems Mirror to speed up downloading gems
RubyGems Mirrors
Please use a newer RubyGems version as much as possible, 2.6.x or above is recommended.
1 | gem update --system |
Replace https://rubygems.org/
with https://gems.ruby-china.com/
or other mirrors.
1 | gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ |
Or mirror https://rubygems.org/
with https://gems.ruby-china.com/
.
1 | bundle config mirror.https://rubygems.org https://gems.ruby-china.com |
It will append the BUNDLE_SET
and value into ~/.bundle/config
.
1 | # ~/.bundle/config |
Or, edit ~/.gemrc
,append https://mirrors.tuna.tsinghua.edu.cn/rubygems/
to sources
fields。
1 |
|
So you don’t need to change the source of your Gemfile.
1 | source 'https://rubygems.org/' |
References
[1] RubyGems 镜像 - Ruby China - https://gems.ruby-china.com/
[2] RubyGems.org | your community gem host - https://rubygems.org/
[3] Run your own gem server - RubyGems Guides - https://guides.rubygems.org/run-your-own-gem-server/
[7] gemrc example - https://gist.github.com/jch/1331576
[8] [class Gem::ConfigFile - Documentation for Ruby 3.0.0 - https://docs.ruby-lang.org/en/3.0.0/Gem/ConfigFile.html(https://docs.ruby-lang.org/en/3.0.0/Gem/ConfigFile.html)