gem与代理设置

来源:互联网 发布:战地4 知乎 编辑:程序博客网 时间:2024/03/28 18:56
I'm behind an authenticated proxy and RubyGems doesn't seem to support username/password based authentication.

Some investigation seems to indicate that open-uri.rb doesn't support authentication. open-uri is based on Net::HTTP
which *does* support authentication so it should be relatively easy to modify open-uri to do that too. I spent about
an hour on it, but couldn't immediately get something working (open-uri is using Net::HTTP in a somewhat quirky way).

C:/>gem -v

C:/>"c:/ruby/bin/ruby.exe" "c:/ruby/bin/gem" -v
0.8.3

C:/>gem list -p http://proxy:8080 -r --backtrace

C:/>"c:/ruby/bin/ruby.exe" "c:/ruby/bin/gem" list -p http://proxy1.macbank:8080 -r --backtrace

*** REMOTE GEMS ***
Updating Gem source index for: http://gems.rubyforge.org
ERROR:  While executing gem ... (OpenURI::HTTPError)
    407 Proxy Authentication Required
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:574:in `proxy_open'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:167:in `open_loop'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:164:in `catch'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:164:in `open_loop'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:134:in `open_uri'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:424:in `open'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:85:in `open'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:96:in `read_data'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:34:in `fetch_path'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:55:in `source_index'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:269:in `source_index'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:400:in `fetch_source'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:391:in `source_index_hash'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:390:in `each'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:390:in `source_index_hash'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:370:in `search'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/gem_commands.rb:376:in `execute'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/gem_commands.rb:459:in `execute'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/command.rb:49:in `invoke'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/cmd_manager.rb:90:in `process_args'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/cmd_manager.rb:63:in `run'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:9:in `run'
c:/ruby/bin/gem:11