app*_*guy 1 ruby proxy vagrant
我已经配置了我的http_proxy变量,并且能够使用curl和apt-get等.但是,当尝试运行诸如"gem install bundler"之类的命令时,我收到代理错误.为了让Ruby像其他工具一样尊重代理,我还需要做些什么吗?
vagrant@mediawiki-vagrant:~$ gem install --debug -V bundler
Exception `NameError' at /usr/lib/ruby/1.9.1/rubygems/command_manager.rb:177 - u
ninitialized constant Gem::Commands::InstallCommand
GET http://rubygems.org/latest_specs.4.8.gz
Exception `Errno::EAGAIN' at /usr/lib/ruby/1.9.1/net/protocol.rb:141 - Resource
temporarily unavailable - read would block
407 Proxy Authentication Required
Exception `Gem::RemoteFetcher::FetchError' at /usr/lib/ruby/1.9.1/rubygems/remot
e_fetcher.rb:222 - bad response Proxy Authentication Required 407 (http://rubyge
ms.org/latest_specs.4.8.gz)
Exception `Gem::RemoteFetcher::FetchError' at /usr/lib/ruby/1.9.1/rubygems/remot
e_fetcher.rb:242 - bad response Proxy Authentication Required 407 (http://rubyge
ms.org/latest_specs.4.8.gz)
Error fetching remote data: bad response Proxy Authentication Requir
ed 407 (http://rubygems.org/latest_specs.4.8.gz)
Falling back to local-only install
Exception `Gem::GemNotFoundException' at /usr/lib/ruby/1.9.1/rubygems/dependency
_installer.rb:237 - Could not find a valid gem 'bundler' (>= 0) locally or in a
repository
ERROR: Could not find a valid gem 'bundler' (>= 0) in any repository
GET http://rubygems.org/latest_specs.4.8.gz
Exception `Errno::EAGAIN' at /usr/lib/ruby/1.9.1/net/protocol.rb:141 - Resource
temporarily unavailable - read would block
407 Proxy Authentication Required
Exception `Gem::RemoteFetcher::FetchError' at /usr/lib/ruby/1.9.1/rubygems/remot
e_fetcher.rb:222 - bad response Proxy Authentication Required 407 (http://rubyge
ms.org/latest_specs.4.8.gz)
Exception `Gem::RemoteFetcher::FetchError' at /usr/lib/ruby/1.9.1/rubygems/remot
e_fetcher.rb:242 - bad response Proxy Authentication Required 407 (http://rubyge
ms.org/latest_specs.4.8.gz)
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Proxy Authentication Required 407 (http://rubygems.org/latest_s
pecs.4.8.gz)
/usr/lib/ruby/1.9.1/rubygems/remote_fetcher.rb:222:in `fetch_http'
/usr/lib/ruby/1.9.1/rubygems/remote_fetcher.rb:238:in `fetch_path'
/usr/lib/ruby/1.9.1/rubygems/spec_fetcher.rb:269:in `load_specs'
/usr/lib/ruby/1.9.1/rubygems/spec_fetcher.rb:231:in `block in list'
/usr/lib/ruby/1.9.1/rubygems/spec_fetcher.rb:227:in `each'
/usr/lib/ruby/1.9.1/rubygems/spec_fetcher.rb:227:in `list'
/usr/lib/ruby/1.9.1/rubygems/spec_fetcher.rb:189:in `suggest_gems_from_n
ame'
/usr/lib/ruby/1.9.1/rubygems/command.rb:160:in `show_lookup_failure'
/usr/lib/ruby/1.9.1/rubygems/commands/install_command.rb:132:in `rescue
in block in execute'
/usr/lib/ruby/1.9.1/rubygems/commands/install_command.rb:116:in `block i
n execute'
/usr/lib/ruby/1.9.1/rubygems/commands/install_command.rb:115:in `each'
/usr/lib/ruby/1.9.1/rubygems/commands/install_command.rb:115:in `execute
'
/usr/lib/ruby/1.9.1/rubygems/command.rb:278:in `invoke'
/usr/lib/ruby/1.9.1/rubygems/command_manager.rb:147:in `process_args'
/usr/lib/ruby/1.9.1/rubygems/command_manager.rb:117:in `run'
/usr/lib/ruby/1.9.1/rubygems/gem_runner.rb:65:in `run'
/usr/bin/gem:21:in `<main>'
Run Code Online (Sandbox Code Playgroud)
小智 8
只是更精确一些.
您的407 Proxy Authentication Required错误意味着您必须使用代理的登录名和密码.
您可以使用该--http-proxy选项添加它,使用以下模式:
gem install --http-proxy http://login:password@proxyServer:proxyPort yourGem
Run Code Online (Sandbox Code Playgroud)
但是,如果您的密码包含一些特殊字符,则无法使用.
实际上,由于选项值必须与URL匹配,因此禁止某些字符.
如果您不确定,gem install可以在执行命令之前在shell中执行以下操作,而不是在命令中指定代理:
set HTTP_PROXY=http://proxyServer:proxyPort
set HTTP_PROXY_USER=login
set HTTP_PROXY_PASS=password
set HTTPS_PROXY=http://proxyServer:proxyPort
set HTTPS_PROXY_USER=login
set HTTPS_PROXY_PASS=password
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9077 次 |
| 最近记录: |