运行下列命令时: gem install pg -v '0.11.0' 出现错误: ERROR: While executing gem ... (Zlib::GzipFile::Error) not in gzip format
好像经常出现这样的错误,是怎么回事啊,怎么解决呢?
#1 楼 @googya 我将 Gemfile 的头一行语句换成了:source 'http://ruby.taobao.org'
bundle install 后,出现下面的错误:
Fetching gem metadata from http://ruby.taobao.org/.
Fetching full source index from http://ruby.taobao.org/
Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:543:in initialize': not in gzip format (Zlib::GzipFile::Error)
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:543:in
new'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:543:in `gunzip'
貌似还是上面类似的错误。
#2 楼 @zhangyuxiu 先运行 gem install 后,出现下列结果:从 Fetching 可以看出,貌似已经找到了要安装的包。 #gem install pg -v '0.11.0' Fetching: pg-0.11.0.gem (100%) ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions into the /usr/local/lib/ruby/gems/1.9.1 directory.
由于权限不够,我以 root 用户重新执行后,仍是得到下面结果:
ERROR: While executing gem ... (Zlib::GzipFile::Error) not in gzip format
我猜想出现这个错误,是不是跟源是没有关系的啊?
#5 楼 @huacnlee 服务器经常出现这种情况么?现在好了么? 我现在运行,出现的结果是:
Building native extensions. This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb checking for pg_config... no No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config checking for libpq-fe.h... no Can't find the 'libpq-fe.h header *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.
Provided configuration options: --with-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/local/bin/ruby --with-pg
你说的服务器,指的是 rubygems 或 taobao.org 源么?