Modify ruby's gem image

Due to network reasons, the download of gem files from rubygems.org is slow or the connection fails intermittently, so you can modify the gem source to https://ruby.taobao.org/ .

The image https://ruby.taobao.org/ was previously maintained by relevant personnel of Taobao, but later due to the departure of the relevant maintainers, this image will no longer be maintained. If you still use this image, the system will prompt you for an error.

Before modifying the gem image, you need to check what the gem image is in your current system, and then delete it accordingly.

The way to view the current gem image is as follows:

Open the cmd window of the computer and enter the following command to view the gem image:

gem sources l

or use directly

gem sources

The query results are as follows:

C:\Users\Administrator>gem sources l
*** CURRENT SOURCES ***

https://rubygems.org/

It indicates that the gem image of https://rubygems.org/ is currently used .

Then use the following command to delete the current gem image:

gem sources -r https://rubygems.org/

The results of successful deletion are as follows:

C:\Users\Administrator>gem sources -r https://rubygems.org/
https://rubygems.org/ removed from sources

After the deletion is successful, add a new image. At this time, if you still use Taobao's image, you will be prompted that an error occurs and the addition is unsuccessful, as follows:

C:\Users\Administrator>gem sources -a https://ruby.taobao.org/
Error fetching https://ruby.taobao.org/:
        SSL_connect returned=1 errno=0 state=error: certificate verify failed (https://gems.ruby-china.org/specs.4.8.gz)

Now the mirror service is provided by ruby-china, that is, we want to switch to this gem mirror: http://gems.ruby-china.org/ , the code is as follows:

gem sources -a http://gems.ruby-china.org/

After executing the above command, if the following result is returned, the update is successful:

C:\Users\Administrator>gem sources -a http://gems.ruby-china.org/
http://gems.ruby-china.org/ added to sources

It should be noted that do not write http as https here, otherwise it will still prompt that the addition fails, as follows:

C:\Users\Administrator>gem sources -a https://gems.ruby-china.org/
Error fetching https://gems.ruby-china.org/:
        SSL_connect returned=1 errno=0 state=error: certificate verify failed (https://gems.ruby-china.org/specs.4.8.gz)

After the mirror switching is successful, downloading resources is relatively faster.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324720633&siteId=291194637