天天看点

【环境】ruby换源

Warning: preg_match(): Compilation failed: unrecognized character after (?< at offset 72 in /home/web/blog/wp-includes/class-wp-embed.php on line 154
在使用gem安装软件时提示连接主机失败

[[email protected] ~]# gem install open4 exception_notification
ERROR:  Could not find a valid gem 'open4' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - Errno::ETIMEDOUT: Connection timed out - connect(2) (https://rubygems.org/latest_specs.4.8.gz)
网上有使用代理的方式,但是个人尝试过不太理想。最好的方式是更换gem源,目前国内最好的就是淘宝的源。

更换方式,首先查看gem源

[[email protected] ~]# gem sources
*** CURRENT SOURCES ***

https://rubygems.org/
添加淘宝源

[[email protected] ~]# gem sources -a http://ruby.taobao.org
http://ruby.taobao.org added to sources
删除ruby官方gem源

[[email protected] ~]# gem sources -r https://rubygems.org/
https://rubygems.org/ removed from sources
再使用gem安装

[[email protected] ~]# gem install open4 exception_notification
Fetching: open4-1.3.4.gem (100%)
Successfully installed open4-1.3.4
Installing ri documentation for open4-1.3.4
Fetching: exception_notification-4.0.1.gem (100%)
Successfully installed exception_notification-4.0.1
Installing ri documentation for exception_notification-4.0.1
2 gems installed
可以看到速度飞快,再次感谢淘宝对互联网的贡献。