If you want to know Ruby,Ruby or want to install several software packages on your computer,You can easily use RubyGems a key to download - just like in the Ubuntu apt-get、Similar redhat in the yum etc.。
so,Want to install Ruby packages,You will need to gem。but,In addition to installing gem (if your computer is Linux or osx,It may have been built,Use the command "gem -v" to verify)
But it may not be the latest version (especially osx,xcode generally will not give you comes with the latest tools) so we need to upgrade it,at this time,You might encounter this error:
1 |
Unable to download data from https://rubygems.org/ |
As for the reason it can not be found or a timeout It depends on the mood of the gfw。Anyway,this is a problem。
But the difficulty is that it seems even with vpn,gem is not how buy it (I do not rule out the issue of vpn),so,We must look for other solutions。
Replace mirroring
Ok,Since it is a package management tool,It is always a source of updates,I found a domestic Taobao update source,This update is a complete image of the source,Update frequency is synchronized once every 15 minutes,We use it to replace an official source。
Taobao Ali cloud image source is located on a server,The official source is located in the Amazon cloud,So you know。
Use the following command to change the gem update source:
1 2 3 4 5 6 |
$ gem sources --remove https://rubygems.org/ $ gem sources -a http://ruby.taobao.org/ $ gem sources -l *** CURRENT SOURCES *** http://ruby.taobao.org //确保只有 ruby.taobao.org |
Then you can try to update the version of the gem:
1 |
gem update --system //你可能需要使用 sudo 命令来获取权限 |
And then………………
enjoy!😜
Original article written by LogStudio:R0uter's Blog » How to use the gem in the country
Reproduced Please keep the source and description link:https://www.logcg.com/archives/1001.html