Forum: Ruby open-uri.rb causing proxy problems?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
A9426492837b45e637b517e81ab43f5f?d=identicon&s=25 Adriano Nagel (Guest)
on 2007-02-01 18:05
(Received via mailing list)

I'm behind a squid proxy trying to install gems, to no avail (the
http_proxy env var is correctly set):

  Error fetching remote gem cache: 407 Proxy Authentication Required

I took a look at gem's remote_fetcher.rb, which in turn uses open-uri
as a wrapper to net/http:

      connection_options = {
        "User-Agent" => "RubyGems/#{Gem::RubyGemsVersion}",
        :proxy => @proxy_uri,
      open(uri, connection_options, &block)

Examining open-uri.rb, I changed the line

      klass = Net::HTTP::Proxy(, proxy.port)


      klass = Net::HTTP::Proxy(, proxy.port, proxy.user,

and it seems to work (probably user and proxy should be URI

Any thoughts?

70ca817f7693bb1c4a847cc9291eb8eb?d=identicon&s=25 Stuart Butler (stuartb)
on 2010-11-10 18:02
Using Ruby 1.9.2, rather than hacking code, this seems to work:

require 'open-uri'
puts open('', :proxy_http_basic_authentication
=> ['http://proxyhost:8080/', 'proxyuser', 'proxypass'] ).readlines

Replace proxyhost with the host name or ip address of your proxy server.
Change 8080 to whatever port it listens on.  Replace proxyuser with the
actual user name you log in to, and proxypass with the actual proxy user

I couldn't find this documented anywhere.
This topic is locked and can not be replied to.