Search code examples
rubyrubygemsamazon-s3natbad-request

Rubygems Bad Request 400 for specs file hosted on Amazon S3


When trying to install gems I run into "Bad Request 400" error when it tries to fetch the specs-file from production.s3.rubygems.org. The problem is same on all Ruby and Rubygems versions.

The system is running on an VMWare ESX hosted Ubuntu 10.10 with Bridged networking behind a NAT switch (Linux -> ESX -> Intranet -> NAT). I have an identical system running on a different ESX on a similiar network that works ok (Linux -> ESX -> Intranet -> Transparent Corporate Firewall+Proxy). Apt-get and other networking works normally.

Is there some way around this or will I have to download all gems manually?

# ping production.s3.rubygems.org
PING s3-1-w.amazonaws.com (72.21.202.165) 56(84) bytes of data.
64 bytes from 72.21.202.165: icmp_req=1 ttl=242 time=139 ms

# gem install -V nokogiri
GET http://rubygems.org/latest_specs.4.8.gz
302 Found
GET http://production.s3.rubygems.org/latest_specs.4.8.gz
400 Bad Request
HEAD http://rubygems.org/specs.4.8.gz
302 Found
HEAD http://production.s3.rubygems.org/specs.4.8.gz
400 Bad Request
HEAD http://rubygems.org/yaml
302 Found
HEAD http://production.s3.rubygems.org/yaml
400 Bad Request
ERROR:  http://rubygems.org/ does not appear to be a repository
Error fetching remote data:             bad response Bad Request 400     (http://production.s3.rubygems.org/yaml)
Falling back to local-only install
ERROR:  Could not find a valid gem 'nokogiri' (>= 0) in any repository

Solution

  • Solved:

    1) Downloaded and copied the http://production.s3.rubygems.org/specs.4.8.gz to the hosts own www-root

    2) Added 127.0.0.1 production.s3.rubygems.org to /etc/hosts