Skip to content

Issue with authentication with proxy #391

tysonite opened this Issue Jan 25, 2012 · 8 comments

8 participants


I try to authenticate on proxy using the following method:
export http_proxy='http://DOMAIN\login:password@'

and it doesn't work with the following message:
[root@host]# gem update
Updating installed gems
ERROR: While executing gem ... (URI::InvalidURIError)
bad URI(is not URI?): http://DOMAIN\login:password@

However, if I exclude "DOMAIN\" string from http_proxy variable it tries to authenticate, but fails (because proxy requires domain name to be included for the user):

[root@host]# export http_proxy='http://login:password@'

[root@host]# gem update
Updating installed gems
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Proxy Authentication Required 407 (

I guess that proxy settings parser should be extended to understand domain name.

rubygems version is
[root@host]# gem -v



I don't have to use the domain variable everywhere... maybe it works for you with this syntax:


But for me it doesn't, don't know what to do... I've set the http_proxy variables for different things. curl, wget, ssh, git and so on - everything tunnels through the http_proxy. Only gem wan't work the way it should. Neither with the --http-proxy or -p params...

@tysonite tysonite referenced this issue in rubygems/rubygems Oct 19, 2012

Issue with authentication with proxy #360


Because of this, I'm already stuck on part 3.2 Creating the Blog Application of the getting started guide of Ruby on Rails.


The problem is related to the uri component of Ruby itself, which tries to match the userinfo part of the URI (i.e. DOMAIN\login) with the following regex:

# userinfo = *( unreserved | escaped | ";" | ":" | "&" | "=" | "+" | "$" | "," | "\" )

whereas the patterns unreserved and escaped do not contain the backslash character. According to the spec (RFC 2396: URI Generic Syntax) this is correct. It reads:

Other characters are excluded because gateways and other transport
agents are known to sometimes modify such characters, or they are
used as delimiters.

unwise = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"

For a quick fix go to \lib\ruby\1.9.1\uri, open common.rb, find userinfo and replace the definition with this line ret[:USERINFO] = userinfo = "(?:[#{unreserved};:&=+$,\\\\]|#{escaped})*"




This should really be fixed, rather than hand modifying ruby libraries

RubyGems member
qrush commented Nov 28, 2014

Not a issue, closing.

@qrush qrush closed this Nov 28, 2014
etxzay commented Mar 17, 2015

@MartinMa Thank you!


or url encode that backslash using %5C as below


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.