gpt4 book ai didi

ruby - 无法在代理后面安装 ruby​​ gem

转载 作者:太空宇宙 更新时间:2023-11-03 17:07:20 26 4
gpt4 key购买 nike

我已经配置了我的 http_proxy 变量,并且能够使用 curl 和 apt-get 等。但是,当尝试运行诸如 gem install bundler 之类的命令时,我收到代理错误。为了让 Ruby 像所有其他工具一样尊重代理,我需要做一些不同的事情吗?

$ gem install --debug -V bundler
Exception `NameError' at /usr/lib/ruby/1.9.1/rubygems/command_manager.rb:177 - uninitialized 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/remote_fetcher.rb:222 - bad response Proxy Authentication Required 407 (http://rubygems.org/latest_specs.4.8.gz)
Exception `Gem::RemoteFetcher::FetchError' at /usr/lib/ruby/1.9.1/rubygems/remote_fetcher.rb:242 - bad response Proxy Authentication Required 407 (http://rubygems.org/latest_specs.4.8.gz)
Error fetching remote data:
bad response Proxy Authentication Required 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/remote_fetcher.rb:222 - bad response Proxy Authentication Required 407 (http://rubygems.org/latest_specs.4.8.gz)
Exception `Gem::RemoteFetcher::FetchError' at /usr/lib/ruby/1.9.1/rubygems/remote_fetcher.rb:242 - bad response Proxy Authentication Required 407 (http://rubygems.org/latest_specs.4.8.gz)
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Proxy Authentication Required 407 (http://rubygems.org/latest_specs.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_name'
/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 in 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>'

最佳答案

只是更精确一些。
您的 407 Proxy Authentication Required 错误意味着您必须为您的代理使用登录名和密码

您可以使用 --http-proxy 选项添加它,模式如下:

gem install --http-proxy http://login:password@proxyServer:proxyPort yourGem

但是,如果您的密码包含一些特殊字符,这将不起作用
实际上,由于选项值必须与 URL 匹配,一些字符是被禁止的。

如果您不确定,您可以在执行命令之前在 shell 中执行以下操作,而不是在 gem install 命令中指定代理:

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

关于ruby - 无法在代理后面安装 ruby​​ gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24791512/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com